grass
grass copied to clipboard
Fix -Wunused-result compiler warnings
Fixes #2128.
Also reported in #2156.
Affects:
Modules
- d.mon
- g.proj
- g.rename
- ps.map
- r.fill.dir
- r.grow.distance
- r.in.ascii
- r.in.bin
- r.in.gridatb
- r.in.mat
- r.param.scale
- r.topmodel
- v.vol.rst
GRASS Library parts
- lib/bitmap
- lib/cairodriver
- lib/db/dbmi_driver
- lib/gis
- lib/rst/interp_float
- lib/vector/Vlib/
Please consider splitting this to modules and library would be helpful. Not only that it will be smaller PRs, but the G_fatal... calls are much more likely to be the correct solution for modules than for the library (although I assume that's what we will end up doing anyway). We can get one of the PRs in faster.
@BadAssassin opened similar PR to this one (#2232), but considers this one better, so that seems like +1 for merging this PR.
I just took a fresh look at this and corrected a regression on bitmap.c which happened during rebase.
Almost exclusively these fixes are file I/O related, handling return values from calls with read()/fread(), write()/fwrite(), fgets(), fscanf(), getcwd(). In general it can be said that what up till now silently failed will now at least be accompanied with a message. I believe this is ready to be merged.
Looks good to me :+1:
Not sure what the scope of this PR is but a quick grep through the main branch, after pulling commits from this PR, reveals some read() calls that need similar treatment. That is, the return value is used without checking for error or ignored altogether. For example, see RTreeReadBranch() and RTreeReadNode() from rtree/io.c, the three read() calls in r.drain/main.c, read_block() from raster3d/r3.in.v5d/binio.c, and several more...
The command I used is
git grep -A 3 '[^a-zA-Z_.(]read('
Looks good to me 👍
👍
Not sure what the scope of this PR is but a quick grep through the main branch, after pulling commits from this PR, reveals some
read()calls that need similar treatment. That is, the return value is used without checking for error or ignored altogether. For example, seeRTreeReadBranch()andRTreeReadNode()from rtree/io.c, the threeread()calls in r.drain/main.c,read_block()from raster3d/r3.in.v5d/binio.c, and several more...
The aim of this PR is as the title suggests, to fix -Wunused-result compiler warnings. One step in a campaign eliminating all -Wall warnings (see eg. #2156).
This been up over half a year. If there are no objections, I will merge this in the next couple of days.