Skip to contentSkip to conversation

af_unix: fix build warning

PATCH In review dingtianhong 2 participants 3 messages Apr 3, 2013 – Apr 4, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 af_unix: fix build warning

net/unix/af_unix.c: In function ‘unix_bind’:
net/unix/af_unix.c:892: warning: ‘path.mnt’ may be used uninitialized in this function net/unix/af_unix.c:892: warning: ‘path.dentry’ may be used uninitialized in this function

---
 net/unix/af_unix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/unix/af_unix.c +1 -1
index 971282b..3ccc049 100644
@@ -889,7 +889,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 	atomic_set(&addr->refcnt, 1);
 
 	if (sun_path[0]) {
-		struct path path;
+		struct path path = {};
 		umode_t mode = S_IFSOCK |
 		       (SOCK_INODE(sock)->i_mode & ~current_umask());
 		err = unix_mknod(sun_path, mode, &path);
Signature · 1 line
1.8.0
#1 lore raw

Hi,
Which version of gcc are you using ?
A patch like yours, for the same method, unix_bind(), was sent in the past, and Stephen Hemminger noted the
with gcc 4.7 the warning you got does not occur.
see:
http://permalink.gmane.org/gmane.linux.network/247807

Best Regards,

Rami Rosen
http://ramirose.wix.com/ramirosen

Quoted 29 lines · dingtianhong

net/unix/af_unix.c: In function ‘unix_bind’:
net/unix/af_unix.c:892: warning: ‘path.mnt’ may be used uninitialized in this function net/unix/af_unix.c:892: warning: ‘path.dentry’ may be used uninitialized in this function

---
 net/unix/af_unix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/unix/af_unix.c +1 -2
index 971282b..3ccc049 100644
@@ -889,7 +889,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
        atomic_set(&addr->refcnt, 1);
 
        if (sun_path[0]) {
-               struct path path;
+               struct path path = {};
                umode_t mode = S_IFSOCK |
                       (SOCK_INODE(sock)->i_mode & ~current_umask());
                err = unix_mknod(sun_path, mode, &path);
--

1.8.0

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 8 lines · Rami Rosen

Hi,
Which version of gcc are you using ?
A patch like yours, for the same method, unix_bind(), was sent in the past, and Stephen Hemminger noted the
with gcc 4.7 the warning you got does not occur.
see:
http://permalink.gmane.org/gmane.linux.network/247807

Quoted 5 lines

Best Regards,

Rami Rosen
http://ramirose.wix.com/ramirosen

ok,thanks

Quoted 33 lines · dingtianhong
Quoted 29 lines

net/unix/af_unix.c: In function ‘unix_bind’:
net/unix/af_unix.c:892: warning: ‘path.mnt’ may be used uninitialized in this function net/unix/af_unix.c:892: warning: ‘path.dentry’ may be used uninitialized in this function

---
 net/unix/af_unix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/unix/af_unix.c +1 -2
index 971282b..3ccc049 100644
@@ -889,7 +889,7 @@ static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
        atomic_set(&addr->refcnt, 1);
 
        if (sun_path[0]) {
-               struct path path;
+               struct path path = {};
                umode_t mode = S_IFSOCK |
                       (SOCK_INODE(sock)->i_mode & ~current_umask());
                err = unix_mknod(sun_path, mode, &path);
--

1.8.0

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html