Skip to contentSkip to conversation

net/l2tpv3: Remove redundant check in net_init_l2tpv3()

PATCH In review AlexChen 2 participants 3 messages Oct 30, 2020 – Nov 11, 2020 Networking

lore
Share & tools
lore

AlexChen

author
#0 lore raw

PATCH 1/1 net/l2tpv3: Remove redundant check in net_init_l2tpv3()

The result has been checked to be NULL before, it cannot be NULL here, so the check is redundant. Remove it.

---
 net/l2tpv3.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
net/l2tpv3.c +3 -6
index 55fea17c0f..e4d4218db6 100644
@@ -655,9 +655,8 @@ int net_init_l2tpv3(const Netdev *netdev,
         error_setg(errp, "could not bind socket err=%i", errno);
         goto outerr;
     }
-    if (result) {
-        freeaddrinfo(result);
-    }
+
+    freeaddrinfo(result);
 
     memset(&hints, 0, sizeof(hints));
 
@@ -686,9 +685,7 @@ int net_init_l2tpv3(const Netdev *netdev,
     memcpy(s->dgram_dst, result->ai_addr, result->ai_addrlen);
     s->dst_size = result->ai_addrlen;
 
-    if (result) {
-        freeaddrinfo(result);
-    }
+    freeaddrinfo(result);
 
     if (l2tpv3->has_counter && l2tpv3->counter) {
         s->has_counter = true;
Signature · 1 line
2.19.1
author
#1 lore raw

Kindly ping.

Quoted 37 lines · AlexChen

The result has been checked to be NULL before, it cannot be NULL here, so the check is redundant. Remove it.

---
 net/l2tpv3.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
net/l2tpv3.c +3 -6
index 55fea17c0f..e4d4218db6 100644
@@ -655,9 +655,8 @@ int net_init_l2tpv3(const Netdev *netdev,
         error_setg(errp, "could not bind socket err=%i", errno);
         goto outerr;
     }
-    if (result) {
-        freeaddrinfo(result);
-    }
+
+    freeaddrinfo(result);
 
     memset(&hints, 0, sizeof(hints));
 
@@ -686,9 +685,7 @@ int net_init_l2tpv3(const Netdev *netdev,
     memcpy(s->dgram_dst, result->ai_addr, result->ai_addrlen);
     s->dst_size = result->ai_addrlen;
 
-    if (result) {
-        freeaddrinfo(result);
-    }
+    freeaddrinfo(result);
 
     if (l2tpv3->has_counter && l2tpv3->counter) {
         s->has_counter = true;
#2 lore raw
Quoted 11 lines · Alex Chen

Kindly ping.

Quoted 8 lines · AlexChen

The result has been checked to be NULL before, it cannot be NULL here, so the check is redundant. Remove it.

---
  net/l2tpv3.c | 9 +++------
  1 file changed, 3 insertions(+), 6 deletions(-)

Queued.

Thanks