Checking return value of function call in C code
When programming in C language, as a general rule, if some function returns a value, you better check it. Given current patterns, this value in more cases than not represents error state (or has the ability to represent an error state). And one better structure the program so that this error checking makes sense when looking at the whole call stack.
Problem is, in Machinekit-HAL, there are numerous parts of the code which do not do this. In code static analysis that means bazillion of errors and warnings.
And on more functional side - given that the Debian-like Docker builder images do export the -Werror flag for any (GCC) compiler with major version lesser than 9 - the building of packages for (and running tests on) Ubuntu Bionic 18.04 LTS needs additional sanitizing of 4 functions. (I don't know which combination of flags causes that [low] number, there are tons of other instances.)
In many cases it is the checking of return value of snprintf() to quiet the truncation warnings.
(This issue is not about discussion if it needs to be done - because it does. [Of course, I am not going to prevent discussion.] But should serve as progress tracker - it's not going to happen in one go.)
+1
I'd like to see commands to reproduce this.
I'd like to see commands to reproduce this.
Commands to reproduce what exactly? The Ubuntu Bionic build? That is in my branch (Actions). I am going to open the pull request once the Python 3 work is merged in and I have to solve the no good, horrible, terrible ports stuff first (so think up some script which will process the /etc/apt/sources.list the right way). But that's off-topic.
You can see the output of static analysis here - it's little stale, but good enough.
linuxcnc recently fixed a number of gcc and static analyzer warnings.