Coverity / static analysis based cleanups

Dirk Hohndel dirk at hohndel.org
Thu Dec 28 16:35:28 PST 2017


This is a series of 14 patches against the current tip of the
Subsurface-branch of libdivecomputer. I believe that all of them should
apply to upstream master (but haven't verified that).

Some of them are clear bug fixes, some of them are equally clear fixes to
avoid memory leaks. A few deal with cases where the current code ignores
the return values of functions - that last type I am not always 100% sure
about my resolution...

All of them were generated based on a Coverity scan of Subsurface, built
on Linux. This series should address all of the currently open Coverity
issues that aren't rather obvious false positives.

As usual, one can argue whether all of these issues are indeed bugs and
how they should be fixed (e.g., should we check return values and return
errors to our callers, or is it safe to ignore certain errors (in which
case that should be done explicitly for consistency)).

Happy to get feedback / comments.

Thanks

/D

[PATCH 01/14] Cleanup: correctly handle upper bound of array
[PATCH 02/14] Cleanup: avoid memory leaks
[PATCH 03/14] Cleanup: avoid memory leak
[PATCH 04/14] Cleanup: avoid memory leak
[PATCH 05/14] Cleanup: avoid memory leak
[PATCH 06/14] Cleanup: ensure string is 0 terminated
[PATCH 07/14] Cleanup: avoid undefined shift operation
[PATCH 08/14] Cleanup: remove dead code and return the correct return
[PATCH 09/14] Cleanup: be explicit about ignoring the return value of
[PATCH 10/14] Cleanup: check return value of ioctl()
[PATCH 11/14] Cleanup: check error return values of buffer handling
[PATCH 12/14] Cleanup: consistenty check return value of iostream
[PATCH 13/14] Cleanup: bail on error
[PATCH 14/14] Cleanup: remove confusing NULL check


More information about the devel mailing list