Skip to contentSkip to conversation

cgroup: Initialize root in cgroup_mount

PATCH In review Jason Low 2 participants 4 messages Jan 27, 2015

lore
Share & tools
lore

Jason Low

author
#0 lore raw

PATCH 1/1 cgroup: Initialize root in cgroup_mount

Compiling kernel/ causes warnings:

... ‘root’ may be used uninitialized in this function ... ‘root’ was declared here

This isn't an issue since there is already logic to not use root if we goto out_unlock without setting root.

Explicitly initialize root to NULL to suppress this so that we can focus on catching warnings that can potentially cause bigger issues.

---
 kernel/cgroup.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/cgroup.c +1 -1
index bb263d0..66684f3 100644
@@ -1738,8 +1738,8 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type,
 			 void *data)
 {
 	struct super_block *pinned_sb = NULL;
+	struct cgroup_root *root = NULL;
 	struct cgroup_subsys *ss;
-	struct cgroup_root *root;
 	struct cgroup_sb_opts opts;
 	struct dentry *dentry;
 	int ret;
Signature · 1 line
1.7.1
#1 lore raw
Quoted 10 lines · Jason Low

Compiling kernel/ causes warnings:

... ‘root’ may be used uninitialized in this function ... ‘root’ was declared here

This isn't an issue since there is already logic to not use root if we goto out_unlock without setting root.

Explicitly initialize root to NULL to suppress this so that we can focus on catching warnings that can potentially cause bigger issues.

Which complier are you using? The variable, AFAICS, is always set before being deref'd and the function hasn't triggered spurious warnings for quite a while with differing versions of gcc.

Thanks.

Signature · 1 line
tejun
author
#2 lore raw
Quoted 6 lines · Tejun Heo
Quoted 5 lines · Jason Low

Compiling kernel/ causes warnings:

... ‘root’ may be used uninitialized in this function ... ‘root’ was declared here

Quoted 7 lines
Quoted 5 lines

This isn't an issue since there is already logic to not use root if we goto out_unlock without setting root.

Explicitly initialize root to NULL to suppress this so that we can focus on catching warnings that can potentially cause bigger issues.

Which complier are you using?

Hi Tejun, one of the versions I am seeing this on is gcc 4.6.3.

Quoted 3 lines

The variable, AFAICS, is always set
before being deref'd and the function hasn't triggered spurious warnings for quite a while with differing versions of gcc.

#3 lore raw
Quoted 10 lines · Jason Low
Quoted 9 lines · Tejun Heo
Quoted 8 lines · Jason Low

Compiling kernel/ causes warnings:

... ‘root’ may be used uninitialized in this function ... ‘root’ was declared here

This isn't an issue since there is already logic to not use root if we goto out_unlock without setting root.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Explicitly initialize root to NULL to suppress this so that we can focus on catching warnings that can potentially cause bigger issues.

Which complier are you using?

Hi Tejun, one of the versions I am seeing this on is gcc 4.6.3.

Can you plesae try something newer? gcc for a while had trouble with these spurious warnings. 4.6.2 is 3+ years old now.

Thanks.

Signature · 1 line
tejun