diff mbox series

net/l2tpv3: Remove redundant check in net_init_l2tpv3()

Message ID 5F9B7E9F.8050004@huawei.com
State New
Headers show
Series net/l2tpv3: Remove redundant check in net_init_l2tpv3() | expand

Commit Message

Alex Chen Oct. 30, 2020, 2:46 a.m. UTC
The result has been checked to be NULL before, it cannot be NULL here,
so the check is redundant. Remove it.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: AlexChen <alex.chen@huawei.com>
---
 net/l2tpv3.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Comments

Alex Chen Nov. 11, 2020, 7:38 a.m. UTC | #1
Kindly ping.

On 2020/10/30 10:46, AlexChen wrote:
> The result has been checked to be NULL before, it cannot be NULL here,
> so the check is redundant. Remove it.
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: AlexChen <alex.chen@huawei.com>
> ---
>  net/l2tpv3.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/net/l2tpv3.c b/net/l2tpv3.c
> index 55fea17c0f..e4d4218db6 100644
> --- a/net/l2tpv3.c
> +++ b/net/l2tpv3.c
> @@ -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;
>
Jason Wang Nov. 11, 2020, 8:53 a.m. UTC | #2
On 2020/11/11 下午3:38, Alex Chen wrote:
> Kindly ping.
>
> On 2020/10/30 10:46, AlexChen wrote:
>> The result has been checked to be NULL before, it cannot be NULL here,
>> so the check is redundant. Remove it.
>>
>> Reported-by: Euler Robot<euler.robot@huawei.com>
>> Signed-off-by: AlexChen<alex.chen@huawei.com>
>> ---
>>   net/l2tpv3.c | 9 +++------
>>   1 file changed, 3 insertions(+), 6 deletions(-)


Queued.

Thanks
diff mbox series

Patch

diff --git a/net/l2tpv3.c b/net/l2tpv3.c
index 55fea17c0f..e4d4218db6 100644
--- a/net/l2tpv3.c
+++ b/net/l2tpv3.c
@@ -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;