Commit 0ba98718 authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by David S. Miller

inet: Avoid unitialized variable warning in inet_unhash()

With gcc-4.1.2:

    net/ipv4/inet_hashtables.c: In function ‘inet_unhash’:
    net/ipv4/inet_hashtables.c:628: warning: ‘ilb’ may be used uninitialized in this function

While this is a false positive, it can easily be avoided by using the
pointer itself as the canary variable.
Signed-off-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 367dc658
...@@ -625,9 +625,8 @@ EXPORT_SYMBOL_GPL(inet_hash); ...@@ -625,9 +625,8 @@ EXPORT_SYMBOL_GPL(inet_hash);
void inet_unhash(struct sock *sk) void inet_unhash(struct sock *sk)
{ {
struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo; struct inet_hashinfo *hashinfo = sk->sk_prot->h.hashinfo;
struct inet_listen_hashbucket *ilb; struct inet_listen_hashbucket *ilb = NULL;
spinlock_t *lock; spinlock_t *lock;
bool listener = false;
if (sk_unhashed(sk)) if (sk_unhashed(sk))
return; return;
...@@ -635,7 +634,6 @@ void inet_unhash(struct sock *sk) ...@@ -635,7 +634,6 @@ void inet_unhash(struct sock *sk)
if (sk->sk_state == TCP_LISTEN) { if (sk->sk_state == TCP_LISTEN) {
ilb = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)]; ilb = &hashinfo->listening_hash[inet_sk_listen_hashfn(sk)];
lock = &ilb->lock; lock = &ilb->lock;
listener = true;
} else { } else {
lock = inet_ehash_lockp(hashinfo, sk->sk_hash); lock = inet_ehash_lockp(hashinfo, sk->sk_hash);
} }
...@@ -645,7 +643,7 @@ void inet_unhash(struct sock *sk) ...@@ -645,7 +643,7 @@ void inet_unhash(struct sock *sk)
if (rcu_access_pointer(sk->sk_reuseport_cb)) if (rcu_access_pointer(sk->sk_reuseport_cb))
reuseport_detach_sock(sk); reuseport_detach_sock(sk);
if (listener) { if (ilb) {
inet_unhash2(hashinfo, sk); inet_unhash2(hashinfo, sk);
__sk_del_node_init(sk); __sk_del_node_init(sk);
ilb->count--; ilb->count--;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment