[GRASS-dev] Fwd: New Defects reported by Coverity Scan for grass
glynn at gclements.plus.com
Tue Nov 4 04:45:29 PST 2014
Markus Neteler wrote:
> I have submitted r62566 from today to Coverity Scan, results below.
> >>> Calling "Rast_read_colors" without checking return value (as is
> done elsewhere 50 out of 61 times).
I'd suggest fixing this by removing the redundant checks and making
the needed check mostly redundant.
While most modules check the return code, exactly what they check for
(==-1, <0, <=0) isn't consistent.
1. Successfully reads a colour table and returns 1.
2. Discovers that the map lacks a colour table, generates a default
rainbow colour table, issues a warning, and returns -2.
3. Discovers that the map's colour table is syntactically invalid,
issues a warning, and returns -1.
The first case isn't an error.
The second case isn't really an error for most modules.
The third case indicates an actual problem (the colour table won't
have been initialised) but it would be straightforward to substitute a
default colour table as per the second case.
For the second and third cases, the module can check the return code
if a default colour table means that its output is going to be garbage
(e.g. modules which use it to translate cell values to a 0..1
intensity value). Otherwise, it can just proceed using the default
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev