Skip to contentSkip to conversation

net: fix compile warning in af_unix.c

PATCH In review Jing Wang 2 participants 3 messages Oct 30, 2012 – Oct 31, 2012

Subsystems (3)
lore
Share & tools
lore

Jing Wang

author
#0 lore raw

PATCH 1/1 net: fix compile warning in af_unix.c

This patch fix some compile warning as follows:
net/unix/af_unix.c: In function 'unix_bind':
net/unix/af_unix.c:895: warning: 'path.dentry' may be used uninitialized in this function net/unix/af_unix.c:895: warning: 'path.mnt' may be used uninitialized in this function

---
 net/unix/af_unix.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
net/unix/af_unix.c +2 -0
index 5b5c876..9f710ac 100644
@@ -895,6 +895,8 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 		struct path path;
 		umode_t mode = S_IFSOCK |
 		       (SOCK_INODE(sock)->i_mode & ~current_umask());
+		path.mnt = NULL;
+		path.dentry = NULL;
 		err = unix_mknod(sun_path, mode, &path);
 		if (err) {
 			if (err == -EEXIST)
Signature · 1 line
1.7.5.4
#1 lore raw
Quoted 15 lines · On Tue, 30 Oct 2012 15:16:36 +0800 Jing Wang <[email protected]> wrote:

This patch fix some compile warning as follows:
net/unix/af_unix.c: In function 'unix_bind':
net/unix/af_unix.c:895: warning: 'path.dentry' may be used uninitialized in this function net/unix/af_unix.c:895: warning: 'path.mnt' may be used uninitialized in this function

---
 net/unix/af_unix.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
net/unix/af_unix.c +0 -0
index 5b5c876..9f710ac 100644

net/unix/af_unix.c static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) · line 902

Quoted 8 lines
net/unix/af_unix.c +2 -0
@@ -895,6 +895,8 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 		struct path path;
 		umode_t mode = S_IFSOCK |
 		       (SOCK_INODE(sock)->i_mode & ~current_umask());
+		path.mnt = NULL;
+		path.dentry = NULL;
 		err = unix_mknod(sun_path, mode, &path);
 		if (err) {
 			if (err == -EEXIST)

I appreciate the effort to silence warnings. But this warning is a false positive that only occurs on some versions of Gcc. With gcc 4.7 the warning does not occur.

The general consensus has been NOT to do initializations or other changes if the problem is due to Gcc bug.

author
#2 lore raw
Quoted 30 lines · Stephen Hemminger
Quoted 15 lines · On Tue, 30 Oct 2012 15:16:36 +0800 Jing Wang <[email protected]> wrote:

This patch fix some compile warning as follows:
net/unix/af_unix.c: In function 'unix_bind':
net/unix/af_unix.c:895: warning: 'path.dentry' may be used uninitialized in this function net/unix/af_unix.c:895: warning: 'path.mnt' may be used uninitialized in this function

---
  net/unix/af_unix.c |    2 ++
  1 files changed, 2 insertions(+), 0 deletions(-)
net/unix/af_unix.c +0 -0
index 5b5c876..9f710ac 100644

net/unix/af_unix.c static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) · line 902

Quoted 8 lines
net/unix/af_unix.c +2 -0
@@ -895,6 +895,8 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
  		struct path path;
  		umode_t mode = S_IFSOCK |
  		       (SOCK_INODE(sock)->i_mode & ~current_umask());
+		path.mnt = NULL;
+		path.dentry = NULL;
  		err = unix_mknod(sun_path, mode, &path);
  		if (err) {
  			if (err == -EEXIST)

I appreciate the effort to silence warnings. But this warning is a false positive that only occurs on some versions of Gcc. With gcc 4.7 the warning does not occur.

Quoted 3 lines

The general consensus has been NOT to do initializations or other changes if the problem is due to Gcc bug.

Thanks for you review, you're right, the version of my gcc is 4.4.6 !