Discussion:
scan-build-11 warnings
Daniel Stenberg via curl-library
2021-05-08 10:14:39 UTC
Permalink
Hi friends!

I ran scan-build-11 against the current git master curl code and it generates
two warnings that I just cannot understand and at the same time I cannot
easily silence.

We use scan-build in the CI (travis), but that runs an older version that
doesn't seem to warn for these issues. No other code analyzer has warned on
these ones either.

For all I can tell, these are false positives. Can *you* find an actual
problem and fix?

https://daniel.haxx.se/scan-build-2021-05-08-115719/

scan-build offers no (good) way to individually switch off false positives!
--
/ daniel.haxx.se
| Commercial curl support up to 24x7 is available!
| Private help, bug fixes, support, ports, new features
| https://www.wolfssl.com/contact/
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.se/ma
Daniel Stenberg via curl-library
2021-05-08 10:31:28 UTC
Permalink
Post by Daniel Stenberg via curl-library
For all I can tell, these are false positives. Can *you* find an actual
problem and fix?
The warnings go away when I move the speed logic into a sub function, which
also makes the code a little nicer:

https://github.com/curl/curl/pull/7035
--
/ daniel.haxx.se
| Commercial curl support up to 24x7 is available!
| Private help, bug fixes, support, ports, new features
| https://www.wolfssl.com/contact/
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: h
Patrick Monnerat via curl-library
2021-05-08 10:34:47 UTC
Permalink
Post by Daniel Stenberg via curl-library
Hi friends!
I ran scan-build-11 against the current git master curl code and it
generates two warnings that I just cannot understand and at the same
time I cannot easily silence.
We use scan-build in the CI (travis), but that runs an older version
that doesn't seem to warn for these issues. No other code analyzer has
warned on these ones either.
For all I can tell, these are false positives. Can *you* find an
actual problem and fix?
IMHO, this is not only a false positive, but a scan-build bug.

Mabe you can silent it by rephrasing the code. In example:

if(timespent <= 0)

  timespent = 1;

.

.

.

data->progress.ulspeed = ul / timespent;

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.se/mail/etique
Daniel Stenberg via curl-library
2021-05-08 10:39:15 UTC
Permalink
Post by Patrick Monnerat via curl-library
IMHO, this is not only a false positive, but a scan-build bug.
I tried a whole bunch of variations like that without success. Until I moved
the entire speed calc logic into a separate function and then voila it is no
longer "bad"! =)
--
/ daniel.haxx.se
| Commercial curl support up to 24x7 is available!
| Private help, bug fixes, support, ports, new features
| https://www.wolfssl.com/contact/
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https
Loading...