Re: [PATCH] [4/23] pagemap: Avoid unused-but-set variable

From: Andi Kleen
Date: Sat Jun 19 2010 - 03:44:19 EST


> 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@xxxxxxxxxxxxxxx -- Speaking for myself only.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/