Prev: DRM / radeon / PM: Do not evict VRAM during freeze phase of hibernation
Next: Drivers: Staging: Fixed several checkpatch.pl issues
From: Andrew Morton on 18 Jun 2010 19:30 On Thu, 10 Jun 2010 13:10:39 +0200 (CEST) Andi Kleen <andi(a)firstfloor.org> wrote: > > Avoid quite a lot of warnings in header files in a gcc 4.6 -Wall builds > > Signed-off-by: Andi Kleen <ak(a)linux.intel.com> > > --- > include/linux/pagemap.h | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > Index: linux-2.6.35-rc2-gcc/include/linux/pagemap.h > =================================================================== > --- linux-2.6.35-rc2-gcc.orig/include/linux/pagemap.h > +++ linux-2.6.35-rc2-gcc/include/linux/pagemap.h > @@ -423,8 +423,10 @@ static inline int fault_in_pages_readabl > const char __user *end = uaddr + size - 1; > > if (((unsigned long)uaddr & PAGE_MASK) != > - ((unsigned long)end & PAGE_MASK)) > + ((unsigned long)end & PAGE_MASK)) { > ret = __get_user(c, end); > + (void)c; > + } > } > return ret; > } urgh. In fact I'd urgh the whole patchset. Problem is, anyone who looks at all these random (void) casts is going to have a hard time working out why they're there. This is worsened by the long-standing practice wherein some people put unneeded (void) casts all over the place due to being traumatised by lint 15 years ago (I think). Wouldn't it be better to make this stuff self-documenting, so anyone who reads the code can immediately see what it's doing, rather than scratching their heads over random, seemingly-unneeded casts? #define gcc_46_is_a_pita(expr) ((void)(expr)) ? -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Andi Kleen on 19 Jun 2010 03:50
> urgh. In fact I'd urgh the whole patchset. > > Problem is, anyone who looks at all these random (void) casts is going There are actually not that many in the patch kit if you read it completely. I think that's nearly the only one outside a macro. > to have a hard time working out why they're there. This is worsened by > the long-standing practice wherein some people put unneeded (void) casts all > over the place due to being traumatised by lint 15 years ago (I think). It's really the same reason why they used this with lints. When I tried it first I started complaining about gcc too (I even filled a gcc bug), then disabled it in my build, but after some contemplation I found it really finds real bugs. > > Wouldn't it be better to make this stuff self-documenting, so anyone > who reads the code can immediately see what it's doing, rather than > scratching their heads over random, seemingly-unneeded casts? > > #define gcc_46_is_a_pita(expr) ((void)(expr)) The warning is really useful and we'll get all used to it. So I went with the plain cast. Maybe some more comments would be useful. -Andi -- ak(a)linux.intel.com -- Speaking for myself only. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ |