[PATCH -mm] sunrpc svc: Shut up bogus uninitialized variable warning

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Linux Kernel Mailing List <linux-kernel@...>
Cc: Greg Banks <gnb@...>, Olaf Kirch <olaf.kirch@...>, David Miller <davem@...>, <netdev@...>
Date: Sunday, September 2, 2007 - 4:09 pm

net/sunrpc/svc.c: In function $B!F(J__svc_create_thread$B!G(J:
net/sunrpc/svc.c:550: warning: $B!F(Joldmask.bits[0u]$B!G(J may be used uninitialized in this function

is a bogus warning, but gcc isn't smart enough to see why. We cannot just
reorganize the code in the function, because we want the set_cpus_allowed()
restore to happen only after the kernel_thread() is forked. Alas, we have
to use cpus_clear() to initialize oldmask instead to keep gcc happy.

Also add some comments to describe what's happening in the function.

Signed-off-by: Satyam Sharma <satyam@infradead.org>

---

 net/sunrpc/svc.c |    7 +++++++
 1 file changed, 7 insertions(+)

--- linux-2.6.23-rc4-mm1/net/sunrpc/svc.c~fix	2007-09-02 22:55:25.000000000 +0530
+++ linux-2.6.23-rc4-mm1/net/sunrpc/svc.c	2007-09-02 23:03:45.000000000 +0530
@@ -568,17 +568,24 @@ __svc_create_thread(svc_thread_fn func, 
 	rqstp->rq_server = serv;
 	rqstp->rq_pool = pool;
 
+	/* Only to prevent gcc warning */
+	cpus_clear(oldmask);
+
+	/* Temporarily change CPU affinity before forking svc thread */
 	if (serv->sv_nrpools > 1)
 		have_oldmask = svc_pool_map_set_cpumask(pool->sp_id, &oldmask);
 
+	/* Will inherit current->cpus_allowed */
 	error = kernel_thread((int (*)(void *)) func, rqstp, 0);
 
+	/* Restore old cpus_allowed */
 	if (have_oldmask)
 		set_cpus_allowed(current, oldmask);
 
 	if (error < 0)
 		goto out_thread;
 	svc_sock_update_bufs(serv);
+
 	error = 0;
 out:
 	return error;
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[-mm patchset] War on warnings, Satyam Sharma, (Sun Sep 2, 4:02 pm)
[PATCH -mm] net/wireless/sysfs.c: Shut up build warning, Satyam Sharma, (Sun Sep 2, 4:11 pm)
[PATCH -mm] sunrpc svc: Shut up bogus uninitialized variable..., Satyam Sharma, (Sun Sep 2, 4:09 pm)
[PATCH -mm] sisusbvga: Fix bug and build warnings, Satyam Sharma, (Sun Sep 2, 4:07 pm)
Re: [PATCH -mm] sisusbvga: Fix bug and build warnings, Satyam Sharma, (Sun Sep 2, 4:32 pm)
Re: [-mm patchset] War on warnings, Jesper Juhl, (Sun Sep 2, 4:04 pm)
Re: [-mm patchset] War on warnings, Satyam Sharma, (Sun Sep 2, 4:39 pm)