Skip to contentSkip to conversation

unix: fix build warning of used uninitialized variable

PATCH In review Wang Weidong 2 participants 3 messages Dec 6, 2013

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

PATCH 1/1 unix: fix build warning of used uninitialized variable

af_unix.c: In function unix_bind
af_unix.c:893: warning: path may be used uninitialized in this function

---
 net/unix/af_unix.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
net/unix/af_unix.c +1 -0
index 01625cc..4155ed3 100644
@@ -893,6 +893,7 @@ 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());
+		memset(&path, 0, sizeof(path));
 		err = unix_mknod(sun_path, mode, &path);
 		if (err) {
 			if (err == -EEXIST)
Signature · 1 line
1.6.0.2
#1 lore raw
Quoted 13 lines · Wang Weidong

af_unix.c: In function unix_bind
af_unix.c:893: warning: path may be used uninitialized in this function

---
 net/unix/af_unix.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
net/unix/af_unix.c +0 -0
index 01625cc..4155ed3 100644

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

Quoted 7 lines
net/unix/af_unix.c +1 -0
@@ -893,6 +893,7 @@ 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());
+		memset(&path, 0, sizeof(path));
 		err = unix_mknod(sun_path, mode, &path);
 		if (err) {
 			if (err == -EEXIST)

You should update your compiler, this patch is not needed.

#2 lore raw
Quoted 9 lines · Eric Dumazet
Quoted 8 lines · Wang Weidong

af_unix.c: In function unix_bind
af_unix.c:893: warning: path may be used uninitialized in this function

---
 net/unix/af_unix.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Quoted 16 lines

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

Quoted 12 lines
net/unix/af_unix.c +1 -0
index 01625cc..4155ed3 100644
@@ -893,6 +893,7 @@ 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());
+		memset(&path, 0, sizeof(path));
 		err = unix_mknod(sun_path, mode, &path);
 		if (err) {
 			if (err == -EEXIST)

You should update your compiler, this patch is not needed.

Ok.

Thanks!

Quoted 3 lines