[Openvpn-devel,1/2] Fix check if iface name is set

Message ID 20190815115203.15467-1-arne@rfc2549.org
State Superseded
Headers show
Series [Openvpn-devel,1/2] Fix check if iface name is set | expand

Commit Message

Arne Schwabe Aug. 15, 2019, 1:52 a.m. UTC
Clang/Android complained

 warning: address of array 'rgi6->iface' will always evaluate to 'true' [-Wpointer-bool-conversion]
          if (rgi6->iface)

iface is a char[16]; So its pointer is always true.

we do a CLEAR(rgi6) always before setting this struct and strcpy the
name into iface. So using strlen instead of checking for the pointer
should be the right fix.
---
 src/openvpn/route.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Antonio Quartulli Aug. 15, 2019, 1:58 a.m. UTC | #1
Hi Arne,

better mark the patches with v2.
They are also both missing the signed-off-by line.

how about git format-patch -v2 -s -2 ? :)

Cheers,

On 15/08/2019 13:52, Arne Schwabe wrote:
> Clang/Android complained
> 
>  warning: address of array 'rgi6->iface' will always evaluate to 'true' [-Wpointer-bool-conversion]
>           if (rgi6->iface)
> 
> iface is a char[16]; So its pointer is always true.
> 
> we do a CLEAR(rgi6) always before setting this struct and strcpy the
> name into iface. So using strlen instead of checking for the pointer
> should be the right fix.
> ---
>  src/openvpn/route.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/openvpn/route.c b/src/openvpn/route.c
> index 5f63fd34..a302746e 100644
> --- a/src/openvpn/route.c
> +++ b/src/openvpn/route.c
> @@ -3349,7 +3349,7 @@ get_default_gateway_ipv6(struct route_ipv6_gateway_info *rgi6,
>              rgi6->flags |= RGI_ADDR_DEFINED;
>          }
>  
> -        if (rgi6->iface)
> +        if (strlen(rgi6->iface))
>          {
>              rgi6->flags |= RGI_IFACE_DEFINED;
>          }
>

Patch

diff --git a/src/openvpn/route.c b/src/openvpn/route.c
index 5f63fd34..a302746e 100644
--- a/src/openvpn/route.c
+++ b/src/openvpn/route.c
@@ -3349,7 +3349,7 @@  get_default_gateway_ipv6(struct route_ipv6_gateway_info *rgi6,
             rgi6->flags |= RGI_ADDR_DEFINED;
         }
 
-        if (rgi6->iface)
+        if (strlen(rgi6->iface))
         {
             rgi6->flags |= RGI_IFACE_DEFINED;
         }