* Avoiding "unused variable" warnings
@ 2003-07-13 15:32 Andrey Borzenkov
2003-07-13 15:46 ` Jeff Garzik
0 siblings, 1 reply; 4+ messages in thread
From: Andrey Borzenkov @ 2003-07-13 15:32 UTC (permalink / raw)
To: linux-kernel
I think I have seen it somewhere but forgot.
Is it possible to create a noop macro that makes compiler believe macro
arguments are used? I mean the case of debug macro that for debug off is
redefined as something like do { } while(0) but then if arguments are used
for debugging purposes only compiler emits warning. Some people do not like
it :)
TIA
-andrey
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Avoiding "unused variable" warnings
2003-07-13 15:32 Avoiding "unused variable" warnings Andrey Borzenkov
@ 2003-07-13 15:46 ` Jeff Garzik
2003-07-13 16:22 ` Alan Cox
0 siblings, 1 reply; 4+ messages in thread
From: Jeff Garzik @ 2003-07-13 15:46 UTC (permalink / raw)
To: Andrey Borzenkov; +Cc: linux-kernel
Andrey Borzenkov wrote:
> I think I have seen it somewhere but forgot.
>
> Is it possible to create a noop macro that makes compiler believe macro
> arguments are used? I mean the case of debug macro that for debug off is
> redefined as something like do { } while(0) but then if arguments are used
> for debugging purposes only compiler emits warning. Some people do not like
> it :)
No need for a macro, just do
(void) var_name;
It doesn't generate any code, and it shuts up the compiler.
Jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Avoiding "unused variable" warnings
2003-07-13 15:46 ` Jeff Garzik
@ 2003-07-13 16:22 ` Alan Cox
2003-07-13 16:45 ` Roman Zippel
0 siblings, 1 reply; 4+ messages in thread
From: Alan Cox @ 2003-07-13 16:22 UTC (permalink / raw)
To: Jeff Garzik; +Cc: Andrey Borzenkov, Linux Kernel Mailing List
On Sul, 2003-07-13 at 16:46, Jeff Garzik wrote:
> No need for a macro, just do
>
> (void) var_name;
>
> It doesn't generate any code, and it shuts up the compiler.
It may do. The proper gcc thing is attribute unused. Both are dangerous
as they hide when the variable becomes really unused
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Avoiding "unused variable" warnings
2003-07-13 16:22 ` Alan Cox
@ 2003-07-13 16:45 ` Roman Zippel
0 siblings, 0 replies; 4+ messages in thread
From: Roman Zippel @ 2003-07-13 16:45 UTC (permalink / raw)
To: Alan Cox; +Cc: Jeff Garzik, Andrey Borzenkov, Linux Kernel Mailing List
Hi,
On 13 Jul 2003, Alan Cox wrote:
> > No need for a macro, just do
> >
> > (void) var_name;
> >
> > It doesn't generate any code, and it shuts up the compiler.
>
> It may do. The proper gcc thing is attribute unused. Both are dangerous
> as they hide when the variable becomes really unused
Function like macros, which throw away their arguments, can be dangerous.
I had a funny bug like this:
kunmap(*pagep++);
bye, Roman
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-07-13 16:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-07-13 15:32 Avoiding "unused variable" warnings Andrey Borzenkov
2003-07-13 15:46 ` Jeff Garzik
2003-07-13 16:22 ` Alan Cox
2003-07-13 16:45 ` Roman Zippel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.