qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 for-2.10 12/18] crypto: introduce some common


From: Longpeng (Mike)
Subject: Re: [Qemu-devel] [PATCH v2 for-2.10 12/18] crypto: introduce some common functions for af_alg backend
Date: Sat, 22 Apr 2017 09:29:19 +0800
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:11.0) Gecko/20120327 Thunderbird/11.0.1


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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]