Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1209857 > unrolled thread

un4i-ss-cipher.c warning

Started byMichal Suchanek <hramrach@gmail.com>
First post2015-08-19 16:40 +0200
Last post2015-08-21 00:10 +0200
Articles 6 — 4 participants

Back to article view | Back to linux.kernel


Contents

  un4i-ss-cipher.c warning Michal Suchanek <hramrach@gmail.com> - 2015-08-19 16:40 +0200
    Re: un4i-ss-cipher.c warning Herbert Xu <herbert@gondor.apana.org.au> - 2015-08-20 07:30 +0200
      Re: un4i-ss-cipher.c warning Maxime Ripard <maxime.ripard@free-electrons.com> - 2015-08-20 08:40 +0200
        Re: un4i-ss-cipher.c warning Herbert Xu <herbert@gondor.apana.org.au> - 2015-08-20 08:50 +0200
    Re: un4i-ss-cipher.c warning Corentin LABBE <clabbe.montjoie@gmail.com> - 2015-08-20 16:00 +0200
      Re: un4i-ss-cipher.c warning Herbert Xu <herbert@gondor.apana.org.au> - 2015-08-21 00:10 +0200

#1209857 — un4i-ss-cipher.c warning

FromMichal Suchanek <hramrach@gmail.com>
Date2015-08-19 16:40 +0200
Subjectun4i-ss-cipher.c warning
Message-ID<pZcH0-eH-25@gated-at.bofh.it>
Hello,

when building a kernel with sunxi crypto driver as merged into the
sinxi-wip branch I get a compiler warning.

I am not sure this is the latest version of the driver. It does not
seem to be in mainline yet.

Thanks

Michal

In file included from /scratch/build/linux/include/linux/printk.h:277:0,
                 from /scratch/build/linux/include/linux/kernel.h:13,
                 from /scratch/build/linux/include/linux/clk.h:16,
                 from
/scratch/build/linux/drivers/crypto/sunxi-ss/sun4i-ss.h:15,
                 from
/scratch/build/linux/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c:17:
/scratch/build/linux/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c: In
function ‘sun4i_ss_cipher_poll’:
/scratch/build/linux/include/linux/dynamic_debug.h:86:3: warning:
‘todo’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
   __dynamic_dev_dbg(&descriptor, dev, fmt, \
   ^
/scratch/build/linux/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c:144:15:
note: ‘todo’ was declared here
  unsigned int todo;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1210149

FromHerbert Xu <herbert@gondor.apana.org.au>
Date2015-08-20 07:30 +0200
Message-ID<pZqAi-3Bi-9@gated-at.bofh.it>
In reply to#1209857
On Wed, Aug 19, 2015 at 04:35:36PM +0200, Michal Suchanek wrote:
> Hello,
> 
> when building a kernel with sunxi crypto driver as merged into the
> sinxi-wip branch I get a compiler warning.
> 
> I am not sure this is the latest version of the driver. It does not
> seem to be in mainline yet.

The warning appears to be spurious as the code always ends up
initialising todo before using it.

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1210176

FromMaxime Ripard <maxime.ripard@free-electrons.com>
Date2015-08-20 08:40 +0200
Message-ID<pZrG1-5if-1@gated-at.bofh.it>
In reply to#1210149

[Multipart message — attachments visible in raw view] — view raw

On Thu, Aug 20, 2015 at 01:29:03PM +0800, Herbert Xu wrote:
> On Wed, Aug 19, 2015 at 04:35:36PM +0200, Michal Suchanek wrote:
> > Hello,
> > 
> > when building a kernel with sunxi crypto driver as merged into the
> > sinxi-wip branch I get a compiler warning.
> > 
> > I am not sure this is the latest version of the driver. It does not
> > seem to be in mainline yet.
> 
> The warning appears to be spurious as the code always ends up
> initialising todo before using it.

Not in the dev_dbg call line 258. If ileft was negative or null, todo
isn't assigned to anything.

I'm not sure whether initializing todo to 0 is the right thing to do
though. Corentin?

Maxime

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

[toc] | [prev] | [next] | [standalone]


#1210192

FromHerbert Xu <herbert@gondor.apana.org.au>
Date2015-08-20 08:50 +0200
Message-ID<pZrPI-5tD-5@gated-at.bofh.it>
In reply to#1210176
On Thu, Aug 20, 2015 at 08:39:00AM +0200, Maxime Ripard wrote:
>
> Not in the dev_dbg call line 258. If ileft was negative or null, todo
> isn't assigned to anything.

If ileft starts out being <= 0, then oleft == ileft will also be
<= 0, in which case the loop never executes.

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1210509

FromCorentin LABBE <clabbe.montjoie@gmail.com>
Date2015-08-20 16:00 +0200
Message-ID<pZyxT-6Jf-79@gated-at.bofh.it>
In reply to#1209857
On 19/08/2015 16:35, Michal Suchanek wrote:
> Hello,
>
> when building a kernel with sunxi crypto driver as merged into the
> sinxi-wip branch I get a compiler warning.
>
> I am not sure this is the latest version of the driver. It does not
> seem to be in mainline yet.
>
> Thanks
>
> Michal
>
> In file included from /scratch/build/linux/include/linux/printk.h:277:0,
>                   from /scratch/build/linux/include/linux/kernel.h:13,
>                   from /scratch/build/linux/include/linux/clk.h:16,
>                   from
> /scratch/build/linux/drivers/crypto/sunxi-ss/sun4i-ss.h:15,
>                   from
> /scratch/build/linux/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c:17:
> /scratch/build/linux/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c: In
> function ‘sun4i_ss_cipher_poll’:
> /scratch/build/linux/include/linux/dynamic_debug.h:86:3: warning:
> ‘todo’ may be used uninitialized in this function
> [-Wmaybe-uninitialized]
>     __dynamic_dev_dbg(&descriptor, dev, fmt, \
>     ^
> /scratch/build/linux/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c:144:15:
> note: ‘todo’ was declared here
>    unsigned int todo;
>

Hello

Thanks for the report, strange that I do not have that warning.
todo is always initialized, since oleft and ileft are always > 0 at start.
But setting todo to 0 is a simple fix.
The following patch will suppress the warning.

Regards

-- >8 --
 From 67f2d0749041b08c4c4ad671ab710b3b83f6dfd3 Mon Sep 17 00:00:00 2001
From: LABBE Corentin <clabbe.montjoie@gmail.com>
Date: Thu, 20 Aug 2015 12:18:46 +0200
Subject: [PATCH] crypto: sun4i-ss: suppress the todo uninitialized warning

Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
---
  drivers/crypto/sunxi-ss/sun4i-ss-cipher.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
index e070c31..9299914 100644
--- a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
+++ b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c
@@ -32,7 +32,7 @@ static int sun4i_ss_opti_poll(struct ablkcipher_request *areq)
  	int i, err = 0;
  	unsigned int ileft = areq->nbytes;
  	unsigned int oleft = areq->nbytes;
-	unsigned int todo;
+	unsigned int todo = 0;
  	struct sg_mapping_iter mi, mo;
  	unsigned int oi, oo; /* offset for in and out */

@@ -141,7 +141,7 @@ static int sun4i_ss_cipher_poll(struct ablkcipher_request *areq)
  	int i, err = 0;
  	unsigned int ileft = areq->nbytes;
  	unsigned int oleft = areq->nbytes;
-	unsigned int todo;
+	unsigned int todo = 0;
  	struct sg_mapping_iter mi, mo;
  	unsigned int oi, oo;	/* offset for in and out */
  	char buf[4 * SS_RX_MAX];/* buffer for linearize SG src */
-- 
2.4.6

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1210758

FromHerbert Xu <herbert@gondor.apana.org.au>
Date2015-08-21 00:10 +0200
Message-ID<pZGc4-16Z-59@gated-at.bofh.it>
In reply to#1210509
On Thu, Aug 20, 2015 at 03:56:39PM +0200, Corentin LABBE wrote:
> 
> Thanks for the report, strange that I do not have that warning.
> todo is always initialized, since oleft and ileft are always > 0 at start.
> But setting todo to 0 is a simple fix.
> The following patch will suppress the warning.

Nack.  Please do not fix spurious uninitialised warnings in this
way.  Not only is this pointless but if someone introduced a real
uninitialised bug later on we'd never catch it because of this.

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web