net: fix waring in af_unix
diff mbox series

Message ID 1539340454-67970-1-git-send-email-kyeongdon.kim@lge.com
State New
Headers show
Series
  • net: fix waring in af_unix
Related show

Commit Message

Kyeongdon Kim Oct. 12, 2018, 10:34 a.m. UTC
This fixes the "'hash' may be used uninitialized in this function"

net/unix/af_unix.c:1041:20: warning: 'hash' may be used uninitialized in this function [-Wmaybe-uninitialized]
  addr->hash = hash ^ sk->sk_type;
                      ^

Signed-off-by: Kyeongdon Kim <kyeongdon.kim@lge.com>
---
 net/unix/af_unix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

David Miller Oct. 16, 2018, 5:16 a.m. UTC | #1
From: Kyeongdon Kim <kyeongdon.kim@lge.com>
Date: Fri, 12 Oct 2018 19:34:14 +0900

> This fixes the "'hash' may be used uninitialized in this function"
> 
> net/unix/af_unix.c:1041:20: warning: 'hash' may be used uninitialized in this function [-Wmaybe-uninitialized]
>   addr->hash = hash ^ sk->sk_type;
>                       ^
> 
> Signed-off-by: Kyeongdon Kim <kyeongdon.kim@lge.com>

Please put the initialization at the start of unix_mkname() as a similar
situation exists elsewhere in this file, and the compiler will eventually
warn there too.

Patch
diff mbox series

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index d1edfa3..e6cecc8 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -989,7 +989,7 @@  static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 	struct sockaddr_un *sunaddr = (struct sockaddr_un *)uaddr;
 	char *sun_path = sunaddr->sun_path;
 	int err;
-	unsigned int hash;
+	unsigned int hash = 0;
 	struct unix_address *addr;
 	struct hlist_head *list;
 	struct path path = { };