Re: [PATCH -mm] sys_semctl gcc 4.1 warning fix

Steven Rostedt
2006-05-10T19:21:32Z

Someone emailed me the bug report for gcc:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=5035

And in this, it showed the trick to initialize self to turn off that
warning.

Would it be OK to define a macro like:

#ifdef CONFIG_SHOW_ALL_UNINIT_WARNINGS
# define init_self(x) x
#else
# define init_self(x) x = x
#endif

Such that we can at least look at the places of bogus uninitialized
warnings and do something like:

Index: ipc/sem.c
===================================================================
--- ipc/sem.c (revision 796)
+++ ipc/sem.c (working copy)
@@ -809,7 +809,7 @@
{
struct sem_array *sma;
int err;
- struct sem_setbuf setbuf;
+ struct sem_setbuf init_self(setbuf);
struct kern_ipc_perm *ipcp;

if(cmd == IPC_SET) {

Seems to work. And if you want to make sure that a place doesn't need it
anymore, use -Winit-self and have a script to do a full make once with
CONFIG_SHOW_ALL_UNINIT_WARNINGS and once with -Winit-self, and make sure
that all the -Winit-self warnings are in the
CONFIG_SHOW_ALL_UNINIT_WARNINGS. Otherwise the init_self isn't needed
anymore.

-- Steve