Re: [PATCH 05/16] vfs: bogus warnings in fs/namei.c

2012-10-10 Thread Al Viro
On Tue, Oct 09, 2012 at 01:07:19PM +, Arnd Bergmann wrote:

> Update: I could actually reproduce the problem now, but it only happens when
> building with 'gcc -s' (i.e. CONFIG_CC_OPTIMIZE_FOR_SIZE). It does happen
> with both gcc-4.6 and with gcc-4.8, and on both x86-64 and ARM. An alternative
> patch that would also make it go away is the variant below, but I think that's
> even worse than the first version I suggested because it makes the binary
> output slightly worse by adding an unnecessary initialization when building 
> with
> 'make -s'.

I can live with that, provided that you give it sane commit message and
your s-o-b.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 05/16] vfs: bogus warnings in fs/namei.c

2012-10-10 Thread Al Viro
On Tue, Oct 09, 2012 at 01:07:19PM +, Arnd Bergmann wrote:

 Update: I could actually reproduce the problem now, but it only happens when
 building with 'gcc -s' (i.e. CONFIG_CC_OPTIMIZE_FOR_SIZE). It does happen
 with both gcc-4.6 and with gcc-4.8, and on both x86-64 and ARM. An alternative
 patch that would also make it go away is the variant below, but I think that's
 even worse than the first version I suggested because it makes the binary
 output slightly worse by adding an unnecessary initialization when building 
 with
 'make -s'.

I can live with that, provided that you give it sane commit message and
your s-o-b.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 05/16] vfs: bogus warnings in fs/namei.c

2012-10-09 Thread Jan Kara
On Tue 09-10-12 13:07:19, Arnd Bergmann wrote:
> On Tuesday 09 October 2012, Arnd Bergmann wrote:
> > On Monday 08 October 2012, Jan Kara wrote:
> > > 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.
> > 
> > I'll drop the patch for now and won't send it from my tree then. I agree
> > that uninitialized_var() is not ideal, but none of the alternatives seemed
> > better.
> > 
> > With my latest compiler, I don't actually see the warnings any more, so
> > maybe someone fixed gcc instead, or this went away after another change.
> > I'll let you know if it comes back so we can discuss about a better fix 
> > then.
> > 
> 
> Update: I could actually reproduce the problem now, but it only happens when
> building with 'gcc -s' (i.e. CONFIG_CC_OPTIMIZE_FOR_SIZE). It does happen
> with both gcc-4.6 and with gcc-4.8, and on both x86-64 and ARM. An alternative
> patch that would also make it go away is the variant below, but I think that's
> even worse than the first version I suggested because it makes the binary
> output slightly worse by adding an unnecessary initialization when building 
> with
> 'make -s'.
  Hum, dumb compiler... I like this patch better and since the extra
initialization is on error path only, I don't think it matters. But
whatever Al likes better.

Honza

> diff --git a/fs/namei.c b/fs/namei.c
> index aa30d19..c3612a5 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -810,6 +810,7 @@ follow_link(struct path *link, struct nameidata *nd, void 
> **p)
>   return error;
>  
>  out_put_nd_path:
> + *p = NULL;
>   path_put(>path);
>   path_put(link);
>   return error;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 05/16] vfs: bogus warnings in fs/namei.c

2012-10-09 Thread Arnd Bergmann
On Tuesday 09 October 2012, Arnd Bergmann wrote:
> On Monday 08 October 2012, Jan Kara wrote:
> > 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.
> 
> I'll drop the patch for now and won't send it from my tree then. I agree
> that uninitialized_var() is not ideal, but none of the alternatives seemed
> better.
> 
> With my latest compiler, I don't actually see the warnings any more, so
> maybe someone fixed gcc instead, or this went away after another change.
> I'll let you know if it comes back so we can discuss about a better fix then.
> 

Update: I could actually reproduce the problem now, but it only happens when
building with 'gcc -s' (i.e. CONFIG_CC_OPTIMIZE_FOR_SIZE). It does happen
with both gcc-4.6 and with gcc-4.8, and on both x86-64 and ARM. An alternative
patch that would also make it go away is the variant below, but I think that's
even worse than the first version I suggested because it makes the binary
output slightly worse by adding an unnecessary initialization when building with
'make -s'.

Arnd

diff --git a/fs/namei.c b/fs/namei.c
index aa30d19..c3612a5 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -810,6 +810,7 @@ follow_link(struct path *link, struct nameidata *nd, void 
**p)
return error;
 
 out_put_nd_path:
+   *p = NULL;
path_put(>path);
path_put(link);
return error;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 05/16] vfs: bogus warnings in fs/namei.c

2012-10-09 Thread Arnd Bergmann
On Monday 08 October 2012, Jan Kara wrote:
> 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.

I'll drop the patch for now and won't send it from my tree then. I agree
that uninitialized_var() is not ideal, but none of the alternatives seemed
better.

With my latest compiler, I don't actually see the warnings any more, so
maybe someone fixed gcc instead, or this went away after another change.
I'll let you know if it comes back so we can discuss about a better fix then.

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


Re: [PATCH 05/16] vfs: bogus warnings in fs/namei.c

2012-10-09 Thread Arnd Bergmann
On Monday 08 October 2012, Jan Kara wrote:
 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.

I'll drop the patch for now and won't send it from my tree then. I agree
that uninitialized_var() is not ideal, but none of the alternatives seemed
better.

With my latest compiler, I don't actually see the warnings any more, so
maybe someone fixed gcc instead, or this went away after another change.
I'll let you know if it comes back so we can discuss about a better fix then.

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


Re: [PATCH 05/16] vfs: bogus warnings in fs/namei.c

2012-10-09 Thread Arnd Bergmann
On Tuesday 09 October 2012, Arnd Bergmann wrote:
 On Monday 08 October 2012, Jan Kara wrote:
  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.
 
 I'll drop the patch for now and won't send it from my tree then. I agree
 that uninitialized_var() is not ideal, but none of the alternatives seemed
 better.
 
 With my latest compiler, I don't actually see the warnings any more, so
 maybe someone fixed gcc instead, or this went away after another change.
 I'll let you know if it comes back so we can discuss about a better fix then.
 

Update: I could actually reproduce the problem now, but it only happens when
building with 'gcc -s' (i.e. CONFIG_CC_OPTIMIZE_FOR_SIZE). It does happen
with both gcc-4.6 and with gcc-4.8, and on both x86-64 and ARM. An alternative
patch that would also make it go away is the variant below, but I think that's
even worse than the first version I suggested because it makes the binary
output slightly worse by adding an unnecessary initialization when building with
'make -s'.

Arnd

diff --git a/fs/namei.c b/fs/namei.c
index aa30d19..c3612a5 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -810,6 +810,7 @@ follow_link(struct path *link, struct nameidata *nd, void 
**p)
return error;
 
 out_put_nd_path:
+   *p = NULL;
path_put(nd-path);
path_put(link);
return error;
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 05/16] vfs: bogus warnings in fs/namei.c

2012-10-09 Thread Jan Kara
On Tue 09-10-12 13:07:19, Arnd Bergmann wrote:
 On Tuesday 09 October 2012, Arnd Bergmann wrote:
  On Monday 08 October 2012, Jan Kara wrote:
   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.
  
  I'll drop the patch for now and won't send it from my tree then. I agree
  that uninitialized_var() is not ideal, but none of the alternatives seemed
  better.
  
  With my latest compiler, I don't actually see the warnings any more, so
  maybe someone fixed gcc instead, or this went away after another change.
  I'll let you know if it comes back so we can discuss about a better fix 
  then.
  
 
 Update: I could actually reproduce the problem now, but it only happens when
 building with 'gcc -s' (i.e. CONFIG_CC_OPTIMIZE_FOR_SIZE). It does happen
 with both gcc-4.6 and with gcc-4.8, and on both x86-64 and ARM. An alternative
 patch that would also make it go away is the variant below, but I think that's
 even worse than the first version I suggested because it makes the binary
 output slightly worse by adding an unnecessary initialization when building 
 with
 'make -s'.
  Hum, dumb compiler... I like this patch better and since the extra
initialization is on error path only, I don't think it matters. But
whatever Al likes better.

Honza

 diff --git a/fs/namei.c b/fs/namei.c
 index aa30d19..c3612a5 100644
 --- a/fs/namei.c
 +++ b/fs/namei.c
 @@ -810,6 +810,7 @@ follow_link(struct path *link, struct nameidata *nd, void 
 **p)
   return error;
  
  out_put_nd_path:
 + *p = NULL;
   path_put(nd-path);
   path_put(link);
   return error;
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 05/16] vfs: bogus warnings in fs/namei.c

2012-10-08 Thread Jan Kara
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 
> Cc: Al Viro 
> Cc: linux-fsde...@vger.kernel.org
> Cc: Jan Kara 
> ---
>  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(, nd, );
>   if (res)
> @@ -1933,7 +1933,7 @@ static int path_lookupat(int dfd, const char *name,
>   if (!err && !(flags & LOOKUP_PARENT)) {
>   err = lookup_last(nd, );
>   while (err > 0) {
> - void *cookie;
> + void *uninitialized_var(cookie);
>   struct path link = path;
>   err = may_follow_link(, nd);
>   if (unlikely(err))
> @@ -2902,7 +2902,7 @@ static struct file *path_openat(int dfd, const char 
> *pathname,
>   error = do_last(nd, , file, op, , 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(, nd);
>   path_put(>path);
> -- 
> 1.7.10
> 
-- 
Jan Kara 
SUSE Labs, CR
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 05/16] vfs: bogus warnings in fs/namei.c

2012-10-08 Thread Jan Kara
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 a...@arndb.de
 Cc: Al Viro v...@zeniv.linux.org.uk
 Cc: linux-fsde...@vger.kernel.org
 Cc: Jan Kara j...@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 j...@suse.cz
SUSE Labs, CR
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/