2020-07-23 07:45:54

by Herbert Xu

[permalink] [raw]
Subject: [PATCH] crypto: sa2ul - Fix build warnings

This patch fixes a bunch of initialiser warnings.

Signed-off-by: Herbert Xu <[email protected]>

diff --git a/drivers/crypto/sa2ul.c b/drivers/crypto/sa2ul.c
index ebcdffcdb686..fc3a8268e2c8 100644
--- a/drivers/crypto/sa2ul.c
+++ b/drivers/crypto/sa2ul.c
@@ -916,7 +916,7 @@ static int sa_cipher_setkey(struct crypto_skcipher *tfm, const u8 *key,
static int sa_aes_cbc_setkey(struct crypto_skcipher *tfm, const u8 *key,
unsigned int keylen)
{
- struct algo_data ad = { 0 };
+ struct algo_data ad = {};
/* Convert the key size (16/24/32) to the key size index (0/1/2) */
int key_idx = (keylen >> 3) - 2;

@@ -936,7 +936,7 @@ static int sa_aes_cbc_setkey(struct crypto_skcipher *tfm, const u8 *key,
static int sa_aes_ecb_setkey(struct crypto_skcipher *tfm, const u8 *key,
unsigned int keylen)
{
- struct algo_data ad = { 0 };
+ struct algo_data ad = {};
/* Convert the key size (16/24/32) to the key size index (0/1/2) */
int key_idx = (keylen >> 3) - 2;

@@ -954,7 +954,7 @@ static int sa_aes_ecb_setkey(struct crypto_skcipher *tfm, const u8 *key,
static int sa_3des_cbc_setkey(struct crypto_skcipher *tfm, const u8 *key,
unsigned int keylen)
{
- struct algo_data ad = { 0 };
+ struct algo_data ad = {};

ad.mci_enc = mci_cbc_3des_enc_array;
ad.mci_dec = mci_cbc_3des_dec_array;
@@ -968,7 +968,7 @@ static int sa_3des_cbc_setkey(struct crypto_skcipher *tfm, const u8 *key,
static int sa_3des_ecb_setkey(struct crypto_skcipher *tfm, const u8 *key,
unsigned int keylen)
{
- struct algo_data ad = { 0 };
+ struct algo_data ad = {};

ad.mci_enc = mci_ecb_3des_enc_array;
ad.mci_dec = mci_ecb_3des_dec_array;
@@ -1233,7 +1233,7 @@ static int sa_cipher_run(struct skcipher_request *req, u8 *iv, int enc)
struct sa_tfm_ctx *ctx =
crypto_skcipher_ctx(crypto_skcipher_reqtfm(req));
struct crypto_alg *alg = req->base.tfm->__crt_alg;
- struct sa_req sa_req = { 0 };
+ struct sa_req sa_req = {};
int ret;

if (!req->cryptlen)
@@ -1344,7 +1344,7 @@ static int sa_sha_run(struct ahash_request *req)
{
struct sa_tfm_ctx *ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req));
struct sa_sha_req_ctx *rctx = ahash_request_ctx(req);
- struct sa_req sa_req = { 0 };
+ struct sa_req sa_req = {};
size_t auth_len;

auth_len = req->nbytes;
@@ -1566,7 +1566,7 @@ static int sa_sha_export(struct ahash_request *req, void *out)

static int sa_sha1_cra_init(struct crypto_tfm *tfm)
{
- struct algo_data ad = { 0 };
+ struct algo_data ad = {};
struct sa_tfm_ctx *ctx = crypto_tfm_ctx(tfm);

sa_sha_cra_init_alg(tfm, "sha1");
@@ -1582,7 +1582,7 @@ static int sa_sha1_cra_init(struct crypto_tfm *tfm)

static int sa_sha256_cra_init(struct crypto_tfm *tfm)
{
- struct algo_data ad = { 0 };
+ struct algo_data ad = {};
struct sa_tfm_ctx *ctx = crypto_tfm_ctx(tfm);

sa_sha_cra_init_alg(tfm, "sha256");
@@ -1598,7 +1598,7 @@ static int sa_sha256_cra_init(struct crypto_tfm *tfm)

static int sa_sha512_cra_init(struct crypto_tfm *tfm)
{
- struct algo_data ad = { 0 };
+ struct algo_data ad = {};
struct sa_tfm_ctx *ctx = crypto_tfm_ctx(tfm);

sa_sha_cra_init_alg(tfm, "sha512");
@@ -1842,7 +1842,7 @@ static int sa_aead_setauthsize(struct crypto_aead *tfm, unsigned int authsize)
static int sa_aead_cbc_sha1_setkey(struct crypto_aead *authenc,
const u8 *key, unsigned int keylen)
{
- struct algo_data ad = { 0 };
+ struct algo_data ad = {};

ad.ealg_id = SA_EALG_ID_AES_CBC;
ad.aalg_id = SA_AALG_ID_HMAC_SHA1;
@@ -1855,7 +1855,7 @@ static int sa_aead_cbc_sha1_setkey(struct crypto_aead *authenc,
static int sa_aead_cbc_sha256_setkey(struct crypto_aead *authenc,
const u8 *key, unsigned int keylen)
{
- struct algo_data ad = { 0 };
+ struct algo_data ad = {};

ad.ealg_id = SA_EALG_ID_AES_CBC;
ad.aalg_id = SA_AALG_ID_HMAC_SHA2_256;
@@ -1869,7 +1869,7 @@ static int sa_aead_run(struct aead_request *req, u8 *iv, int enc)
{
struct crypto_aead *tfm = crypto_aead_reqtfm(req);
struct sa_tfm_ctx *ctx = crypto_aead_ctx(tfm);
- struct sa_req sa_req = { 0 };
+ struct sa_req sa_req = {};
size_t auth_size, enc_size;

enc_size = req->cryptlen;
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


2020-07-23 09:58:15

by Tero Kristo

[permalink] [raw]
Subject: Re: [PATCH] crypto: sa2ul - Fix build warnings

On 23/07/2020 10:43, Herbert Xu wrote:
> This patch fixes a bunch of initialiser warnings.
>
> Signed-off-by: Herbert Xu <[email protected]>

Looks ok to me, however I never saw any build warnings with the code
myself. Which compiler/version produces them?

-Tero

>
> diff --git a/drivers/crypto/sa2ul.c b/drivers/crypto/sa2ul.c
> index ebcdffcdb686..fc3a8268e2c8 100644
> --- a/drivers/crypto/sa2ul.c
> +++ b/drivers/crypto/sa2ul.c
> @@ -916,7 +916,7 @@ static int sa_cipher_setkey(struct crypto_skcipher *tfm, const u8 *key,
> static int sa_aes_cbc_setkey(struct crypto_skcipher *tfm, const u8 *key,
> unsigned int keylen)
> {
> - struct algo_data ad = { 0 };
> + struct algo_data ad = {};
> /* Convert the key size (16/24/32) to the key size index (0/1/2) */
> int key_idx = (keylen >> 3) - 2;
>
> @@ -936,7 +936,7 @@ static int sa_aes_cbc_setkey(struct crypto_skcipher *tfm, const u8 *key,
> static int sa_aes_ecb_setkey(struct crypto_skcipher *tfm, const u8 *key,
> unsigned int keylen)
> {
> - struct algo_data ad = { 0 };
> + struct algo_data ad = {};
> /* Convert the key size (16/24/32) to the key size index (0/1/2) */
> int key_idx = (keylen >> 3) - 2;
>
> @@ -954,7 +954,7 @@ static int sa_aes_ecb_setkey(struct crypto_skcipher *tfm, const u8 *key,
> static int sa_3des_cbc_setkey(struct crypto_skcipher *tfm, const u8 *key,
> unsigned int keylen)
> {
> - struct algo_data ad = { 0 };
> + struct algo_data ad = {};
>
> ad.mci_enc = mci_cbc_3des_enc_array;
> ad.mci_dec = mci_cbc_3des_dec_array;
> @@ -968,7 +968,7 @@ static int sa_3des_cbc_setkey(struct crypto_skcipher *tfm, const u8 *key,
> static int sa_3des_ecb_setkey(struct crypto_skcipher *tfm, const u8 *key,
> unsigned int keylen)
> {
> - struct algo_data ad = { 0 };
> + struct algo_data ad = {};
>
> ad.mci_enc = mci_ecb_3des_enc_array;
> ad.mci_dec = mci_ecb_3des_dec_array;
> @@ -1233,7 +1233,7 @@ static int sa_cipher_run(struct skcipher_request *req, u8 *iv, int enc)
> struct sa_tfm_ctx *ctx =
> crypto_skcipher_ctx(crypto_skcipher_reqtfm(req));
> struct crypto_alg *alg = req->base.tfm->__crt_alg;
> - struct sa_req sa_req = { 0 };
> + struct sa_req sa_req = {};
> int ret;
>
> if (!req->cryptlen)
> @@ -1344,7 +1344,7 @@ static int sa_sha_run(struct ahash_request *req)
> {
> struct sa_tfm_ctx *ctx = crypto_ahash_ctx(crypto_ahash_reqtfm(req));
> struct sa_sha_req_ctx *rctx = ahash_request_ctx(req);
> - struct sa_req sa_req = { 0 };
> + struct sa_req sa_req = {};
> size_t auth_len;
>
> auth_len = req->nbytes;
> @@ -1566,7 +1566,7 @@ static int sa_sha_export(struct ahash_request *req, void *out)
>
> static int sa_sha1_cra_init(struct crypto_tfm *tfm)
> {
> - struct algo_data ad = { 0 };
> + struct algo_data ad = {};
> struct sa_tfm_ctx *ctx = crypto_tfm_ctx(tfm);
>
> sa_sha_cra_init_alg(tfm, "sha1");
> @@ -1582,7 +1582,7 @@ static int sa_sha1_cra_init(struct crypto_tfm *tfm)
>
> static int sa_sha256_cra_init(struct crypto_tfm *tfm)
> {
> - struct algo_data ad = { 0 };
> + struct algo_data ad = {};
> struct sa_tfm_ctx *ctx = crypto_tfm_ctx(tfm);
>
> sa_sha_cra_init_alg(tfm, "sha256");
> @@ -1598,7 +1598,7 @@ static int sa_sha256_cra_init(struct crypto_tfm *tfm)
>
> static int sa_sha512_cra_init(struct crypto_tfm *tfm)
> {
> - struct algo_data ad = { 0 };
> + struct algo_data ad = {};
> struct sa_tfm_ctx *ctx = crypto_tfm_ctx(tfm);
>
> sa_sha_cra_init_alg(tfm, "sha512");
> @@ -1842,7 +1842,7 @@ static int sa_aead_setauthsize(struct crypto_aead *tfm, unsigned int authsize)
> static int sa_aead_cbc_sha1_setkey(struct crypto_aead *authenc,
> const u8 *key, unsigned int keylen)
> {
> - struct algo_data ad = { 0 };
> + struct algo_data ad = {};
>
> ad.ealg_id = SA_EALG_ID_AES_CBC;
> ad.aalg_id = SA_AALG_ID_HMAC_SHA1;
> @@ -1855,7 +1855,7 @@ static int sa_aead_cbc_sha1_setkey(struct crypto_aead *authenc,
> static int sa_aead_cbc_sha256_setkey(struct crypto_aead *authenc,
> const u8 *key, unsigned int keylen)
> {
> - struct algo_data ad = { 0 };
> + struct algo_data ad = {};
>
> ad.ealg_id = SA_EALG_ID_AES_CBC;
> ad.aalg_id = SA_AALG_ID_HMAC_SHA2_256;
> @@ -1869,7 +1869,7 @@ static int sa_aead_run(struct aead_request *req, u8 *iv, int enc)
> {
> struct crypto_aead *tfm = crypto_aead_reqtfm(req);
> struct sa_tfm_ctx *ctx = crypto_aead_ctx(tfm);
> - struct sa_req sa_req = { 0 };
> + struct sa_req sa_req = {};
> size_t auth_size, enc_size;
>
> enc_size = req->cryptlen;
>

--
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki

2020-07-23 13:17:56

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] crypto: sa2ul - Fix build warnings

On Thu, Jul 23, 2020 at 12:57:23PM +0300, Tero Kristo wrote:
> On 23/07/2020 10:43, Herbert Xu wrote:
> > This patch fixes a bunch of initialiser warnings.
> >
> > Signed-off-by: Herbert Xu <[email protected]>
>
> Looks ok to me, however I never saw any build warnings with the code myself.
> Which compiler/version produces them?

You're right. I was getting it due to an out-of-date version of
sparse. Please disregard this patch.

Thanks,
--
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt