Message ID | 20240516193700.212737-5-mkp@redhat.com |
---|---|
State | Changes Requested, archived |
Headers | show |
Series | clang: Fix Clang's static analyzer detections. | expand |
Context | Check | Description |
---|---|---|
ovsrobot/apply-robot | success | apply and check: success |
ovsrobot/github-robot-_Build_and_Test | success | github build: passed |
ovsrobot/intel-ovs-compilation | success | test: success |
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 <mkp@redhat.com> > --- 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.
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) {
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 <mkp@redhat.com> --- lib/socket-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)