On 2017/4/21 20:36, Gonglei (Arei) wrote:
>
>> -----Original Message-----
>> +#include "qemu/osdep.h"
>> +#include "qemu/cutils.h"
>> +#include "qemu/sockets.h"
>> +#include "qapi/error.h"
>> +#include "afalgpriv.h"
>> +
>> +static bool
>> +qcrypto_afalg_build_saddr(const char *type, const char *name,
>> + struct sockaddr_alg *salg, Error **errp)
>> +{
>> + memset(salg, 0, sizeof(*salg));
>
> Why not initialize it in its caller?
>
Ok, will fix in v3.
>> + salg->salg_family = AF_ALG;
>> +
>> + if (qemu_strnlen(type, SALG_TYPE_LEN_MAX) == SALG_TYPE_LEN_MAX)
>> {
>> +
>> +QCryptoAFAlg *
>> +qcrypto_afalg_comm_alloc(const char *type, const char *name,
>> + Error **errp)
>> +{
>> + QCryptoAFAlg *afalg = NULL;
>
> A superfluous initialization.
>
Ok.
>> +
>> + afalg = g_new0(QCryptoAFAlg, 1);
>> + /* initilize crypto API socket */
>> + afalg->opfd = -1;
>> + afalg->tfmfd = qcrypto_afalg_socket_bind(type, name, errp);
>> + if (afalg->tfmfd == -1) {
>> + goto error;
>> + }
>> +
>> + afalg->opfd = qemu_accept(afalg->tfmfd, NULL, 0);
>> + if (afalg->opfd == -1) {
>> + error_setg_errno(errp, errno, "Failed to accept socket");
>> + goto error;
>> + }
>> +
>> + return afalg;
>> +
>> +error:
>> + qcrypto_afalg_comm_free(afalg);
>> + return NULL;
>> +}
>> +/**
>> + * qcrypto_afalg_comm_alloc:
>> + * @type: the type of crypto opeartion
>> + * @name: the name of crypto opeartion
>
> s/opeartion/operation/g
>
Ok.
Thanks.
>
>> + *
>> + * Allocate a QCryptoAFAlg object and bind itself to
>> + * a AF_ALG socket.
>> + *
>> + * Returns:
>> + * a new QCryptoAFAlg object, or NULL in error.
>> + */
>> +QCryptoAFAlg *
>> +qcrypto_afalg_comm_alloc(const char *type, const char *name,
>> + Error **errp);
>> +
>> +/**
>> + * afalg_comm_free:
>> + * @afalg: the QCryptoAFAlg object
>> + *
>> + * Free the @afalg.
>> + */
>> +void qcrypto_afalg_comm_free(QCryptoAFAlg *afalg);
>> +
>> +#endif
>> --
>> 1.8.3.1
>>
>
> .
>
--
Regards,
Longpeng(Mike)