* [PATCH 1/1] cgroup: fix var may be used uninitialized warning
@ 2015-03-03 8:59 Javier Martinez Canillas
[not found] ` <1425373187-7227-1-git-send-email-javier.martinez-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Javier Martinez Canillas @ 2015-03-03 8:59 UTC (permalink / raw)
To: Tejun Heo; +Cc: Li Zefan, cgroups, linux-kernel, Javier Martinez Canillas
When building cgroup, GCC warns that the root variable
may be used uninitialized in the cgroup_mount function.
kernel/cgroup.c: In function ‘cgroup_mount’:
kernel/cgroup.c:1886:13: warning: ‘root’ may be used uninitialized in this function [-Wuninitialized]
kernel/cgroup.c:1742:22: note: ‘root’ was declared here
This can never happen because if the struct cgroup_root
can't be allocated, ret is set to -ENOMEM and the error
returned so the code using root is not reachable. But
set root to NULL just to silence the compiler warning.
Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
---
This patch is on top of today's linux-next (tag: next-20150303).
kernel/cgroup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 9a567836ee3a..bf1172d1c831 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1739,7 +1739,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
{
struct super_block *pinned_sb = NULL;
struct cgroup_subsys *ss;
- struct cgroup_root *root;
+ struct cgroup_root *root = NULL;
struct cgroup_sb_opts opts;
struct dentry *dentry;
int ret;
--
2.1.3
^ permalink raw reply related [flat|nested] 3+ messages in thread[parent not found: <1425373187-7227-1-git-send-email-javier.martinez-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>]
* Re: [PATCH 1/1] cgroup: fix var may be used uninitialized warning [not found] ` <1425373187-7227-1-git-send-email-javier.martinez-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org> @ 2015-03-03 13:46 ` Tejun Heo [not found] ` <20150303134642.GD3122-piEFEHQLUPpN0TnZuCh8vA@public.gmane.org> 0 siblings, 1 reply; 3+ messages in thread From: Tejun Heo @ 2015-03-03 13:46 UTC (permalink / raw) To: Javier Martinez Canillas Cc: Li Zefan, cgroups-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA On Tue, Mar 03, 2015 at 09:59:47AM +0100, Javier Martinez Canillas wrote: > When building cgroup, GCC warns that the root variable > may be used uninitialized in the cgroup_mount function. > > kernel/cgroup.c: In function ‘cgroup_mount’: > kernel/cgroup.c:1886:13: warning: ‘root’ may be used uninitialized in this function [-Wuninitialized] > kernel/cgroup.c:1742:22: note: ‘root’ was declared here > > This can never happen because if the struct cgroup_root > can't be allocated, ret is set to -ENOMEM and the error > returned so the code using root is not reachable. But > set root to NULL just to silence the compiler warning. Which compiler are you on? Thanks. -- tejun ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <20150303134642.GD3122-piEFEHQLUPpN0TnZuCh8vA@public.gmane.org>]
* Re: [PATCH 1/1] cgroup: fix var may be used uninitialized warning [not found] ` <20150303134642.GD3122-piEFEHQLUPpN0TnZuCh8vA@public.gmane.org> @ 2015-03-03 15:12 ` Javier Martinez Canillas 0 siblings, 0 replies; 3+ messages in thread From: Javier Martinez Canillas @ 2015-03-03 15:12 UTC (permalink / raw) To: Tejun Heo Cc: Li Zefan, cgroups-u79uwXL29TY76Z2rM5mHXA, linux-kernel-u79uwXL29TY76Z2rM5mHXA Hello Tejun, On 03/03/2015 02:46 PM, Tejun Heo wrote: > On Tue, Mar 03, 2015 at 09:59:47AM +0100, Javier Martinez Canillas wrote: >> When building cgroup, GCC warns that the root variable >> may be used uninitialized in the cgroup_mount function. >> >> kernel/cgroup.c: In function ‘cgroup_mount’: >> kernel/cgroup.c:1886:13: warning: ‘root’ may be used uninitialized in this function [-Wuninitialized] >> kernel/cgroup.c:1742:22: note: ‘root’ was declared here >> >> This can never happen because if the struct cgroup_root >> can't be allocated, ret is set to -ENOMEM and the error >> returned so the code using root is not reachable. But >> set root to NULL just to silence the compiler warning. > > Which compiler are you on? > Yeah, I noticed that I was using a pretty old 4.7.2 GCC on that machine and the warning indeed is not seen with 4.9.1. Sorry for the noise... > Thanks. > Best regard, Javier ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-03 15:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-03 8:59 [PATCH 1/1] cgroup: fix var may be used uninitialized warning Javier Martinez Canillas
[not found] ` <1425373187-7227-1-git-send-email-javier.martinez-ZGY8ohtN/8pPYcu2f3hruQ@public.gmane.org>
2015-03-03 13:46 ` Tejun Heo
[not found] ` <20150303134642.GD3122-piEFEHQLUPpN0TnZuCh8vA@public.gmane.org>
2015-03-03 15:12 ` Javier Martinez Canillas
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox