Re: [ovs-dev] [PATCH 4/5] socket: Fix Clang's static analyzer 'garbage value' warnings.

2024-05-17 Thread Ilya Maximets
On 5/16/24 21:36, Mike Pattrick wrote:
> Clang's static analyzer will complain about an uninitialized value
> because we weren't setting a value for dns_failure in all code paths.
> 
> Now we initialize this on declaration.
> 
> Signed-off-by: Mike Pattrick 
> ---

Same comments for the subject line and a Fixes tag.

>  lib/socket-util.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/socket-util.c b/lib/socket-util.c
> index 2d89fce85..1d21ce01c 100644
> --- a/lib/socket-util.c
> +++ b/lib/socket-util.c
> @@ -711,7 +711,7 @@ inet_open_passive(int style, const char *target, int 
> default_port,
>  struct sockaddr_storage ss;
>  int fd = 0, error;
>  unsigned int yes = 1;
> -bool dns_failure;
> +bool dns_failure = false;
>  
>  if (!inet_parse_passive(target, default_port, &ss, true, &dns_failure)) {
>  if (dns_failure) {

I'm not sure this is a right solution.  inet_parse_passive() should set
the 'dns_failure' whenever it fails, i.e. it should set 'dns_failure'
in every condition where it sets ok = false.

inet_parse_passive() is also not a static function, so we should fix it
instead, so other potential users do not have this issue.

While at it, inet_parse_active() has the same problem.  It should set
the 'dns_failure' whenever it fails.

Best regards, Ilya Maximets.
___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev


[ovs-dev] [PATCH 4/5] socket: Fix Clang's static analyzer 'garbage value' warnings.

2024-05-16 Thread Mike Pattrick
Clang's static analyzer will complain about an uninitialized value
because we weren't setting a value for dns_failure in all code paths.

Now we initialize this on declaration.

Signed-off-by: Mike Pattrick 
---
 lib/socket-util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/socket-util.c b/lib/socket-util.c
index 2d89fce85..1d21ce01c 100644
--- a/lib/socket-util.c
+++ b/lib/socket-util.c
@@ -711,7 +711,7 @@ inet_open_passive(int style, const char *target, int 
default_port,
 struct sockaddr_storage ss;
 int fd = 0, error;
 unsigned int yes = 1;
-bool dns_failure;
+bool dns_failure = false;
 
 if (!inet_parse_passive(target, default_port, &ss, true, &dns_failure)) {
 if (dns_failure) {
-- 
2.39.3

___
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev