From: jack@suse.cz (Jan Kara)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 05/16] vfs: bogus warnings in fs/namei.c
Date: Mon, 8 Oct 2012 13:51:16 +0200 [thread overview]
Message-ID: <20121008115116.GA9243@quack.suse.cz> (raw)
In-Reply-To: <1349448930-23976-6-git-send-email-arnd@arndb.de>
On Fri 05-10-12 16:55:19, Arnd Bergmann wrote:
> The follow_link() function always initializes its *p argument,
> or returns an error, but not all versions of gcc figure this
> out, so we have to work around this using the uninitialized_var()
> macro.
Well, I'm somewhat sceptical to this approach. I agree that bogus
warnings are not nice but later when the code is changed and possibly real
use without initialization is added, we won't notice it. Without changing
anything, we'd at least have a chance of catching it with gcc versions
which were clever enough to not warn with the original code. Or
alternatively if we unconditionally initialized the variable that would get
rid of the warning and made the code more future-proof (that's what I
usually end up doing)... I don't really care that much about the chosen
solution, Al is the one to decide. But I wanted to point out there are
downsides to your solution.
Honza
>
> Without this patch, building with arm-linux-gnueabi-gcc-4.6 results in:
>
> fs/namei.c: In function 'link_path_walk':
> fs/namei.c:649:24: warning: 'cookie' may be used uninitialized in this function [-Wuninitialized]
> fs/namei.c:1544:9: note: 'cookie' was declared here
> fs/namei.c: In function 'path_lookupat':
> fs/namei.c:649:24: warning: 'cookie' may be used uninitialized in this function [-Wuninitialized]
> fs/namei.c:1934:10: note: 'cookie' was declared here
> fs/namei.c: In function 'path_openat':
> fs/namei.c:649:24: warning: 'cookie' may be used uninitialized in this function [-Wuninitialized]
> fs/namei.c:2899:9: note: 'cookie' was declared here
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Cc: Al Viro <viro@zeniv.linux.org.uk>
> Cc: linux-fsdevel at vger.kernel.org
> Cc: Jan Kara <jack@suse.cz>
> ---
> fs/namei.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/namei.c b/fs/namei.c
> index dd1ed1b..62a1725 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -1543,7 +1543,7 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
>
> do {
> struct path link = *path;
> - void *cookie;
> + void *uninitialized_var(cookie);
>
> res = follow_link(&link, nd, &cookie);
> if (res)
> @@ -1933,7 +1933,7 @@ static int path_lookupat(int dfd, const char *name,
> if (!err && !(flags & LOOKUP_PARENT)) {
> err = lookup_last(nd, &path);
> while (err > 0) {
> - void *cookie;
> + void *uninitialized_var(cookie);
> struct path link = path;
> err = may_follow_link(&link, nd);
> if (unlikely(err))
> @@ -2902,7 +2902,7 @@ static struct file *path_openat(int dfd, const char *pathname,
> error = do_last(nd, &path, file, op, &opened, pathname);
> while (unlikely(error > 0)) { /* trailing symlink */
> struct path link = path;
> - void *cookie;
> + void *uninitialized_var(cookie);
> if (!(nd->flags & LOOKUP_FOLLOW)) {
> path_put_conditional(&path, nd);
> path_put(&nd->path);
> --
> 1.7.10
>
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
next prev parent reply other threads:[~2012-10-08 11:51 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-05 14:55 [PATCH 00/16] ARM: mostly harmless gcc warnings Arnd Bergmann
2012-10-05 14:55 ` [PATCH 01/16] ARM: warnings in arch/arm/include/asm/uaccess.h Arnd Bergmann
2012-10-08 5:49 ` Greg Ungerer
2012-10-09 12:08 ` Arnd Bergmann
2012-10-05 14:55 ` [PATCH 02/16] ARM: binfmt_flat: unused variable 'persistent' Arnd Bergmann
2012-10-08 5:50 ` Greg Ungerer
2012-10-05 14:55 ` [PATCH 03/16] SCSI: ARM: ncr5380/oak uses no interrupts Arnd Bergmann
2012-10-05 14:55 ` [PATCH 04/16] SCSI: ARM: make fas216_dumpinfo function conditional Arnd Bergmann
2012-10-05 14:55 ` [PATCH 05/16] vfs: bogus warnings in fs/namei.c Arnd Bergmann
2012-10-08 11:51 ` Jan Kara [this message]
2012-10-09 12:27 ` Arnd Bergmann
2012-10-09 13:07 ` Arnd Bergmann
2012-10-09 13:43 ` Jan Kara
2012-10-11 4:37 ` Al Viro
2012-10-11 13:20 ` [PATCH v2] " Arnd Bergmann
2012-10-05 14:55 ` [PATCH 06/16] mm/slob: use min_t() to compare ARCH_SLAB_MINALIGN Arnd Bergmann
2012-10-05 16:46 ` Christoph Lameter
2012-10-31 7:25 ` Pekka Enberg
2012-10-05 14:55 ` [PATCH 07/16] cgroup: fix warning when building without any subsys Arnd Bergmann
2012-10-05 15:50 ` Ben Blum
2012-10-06 2:14 ` Tejun Heo
2012-10-06 6:19 ` Arnd Bergmann
2012-10-05 14:55 ` [PATCH 08/16] ipvs: fix ip_vs_set_timeout debug messages Arnd Bergmann
2012-10-05 20:39 ` Julian Anastasov
2012-10-06 6:45 ` Arnd Bergmann
2012-10-06 8:09 ` Julian Anastasov
2012-10-06 9:54 ` Arnd Bergmann
2012-10-09 1:48 ` Simon Horman
2012-10-05 14:55 ` [PATCH 09/16] USB: EHCI: mark ehci_orion_conf_mbus_windows __devinit Arnd Bergmann
2012-10-05 18:05 ` Alan Stern
2012-10-05 14:55 ` [PATCH 10/16] clk: don't mark clkdev_add_table as init Arnd Bergmann
2012-10-05 14:55 ` [PATCH 11/16] pcmcia: sharpsl: don't discard sharpsl_pcmcia_ops Arnd Bergmann
2012-10-05 14:55 ` [PATCH 12/16] video: mark nuc900fb_map_video_memory as __devinit Arnd Bergmann
2012-10-05 14:55 ` [PATCH 13/16] ARM: be really quiet when building with 'make -s' Arnd Bergmann
2012-10-05 16:36 ` Nicolas Pitre
2012-10-05 14:55 ` [PATCH 14/16] ARM: pxa: armcore: fix PCI PIO warnings Arnd Bergmann
2012-10-05 15:32 ` Igor Grinberg
2012-10-05 14:55 ` [PATCH 15/16] spi/s3c64xx: use correct dma_transfer_direction type Arnd Bergmann
2012-10-05 14:55 ` [PATCH 16/16] ARM: pass -marm to gcc by default for both C and assembler Arnd Bergmann
2012-10-05 18:42 ` Nicolas Pitre
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121008115116.GA9243@quack.suse.cz \
--to=jack@suse.cz \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).