Re: [PATCH 0/1] Using sparse in a CI job
From: Luc Van Oostenryck <hidden>
Date: 2019-02-01 22:40:07
On Fri, Feb 01, 2019 at 09:01:20PM +0000, Ramsay Jones wrote:
I suspect that the Makefile sparse target is not easy to use in a CI job, since the 'sparse' program (via cgcc -no-compile) does not exit with a non-zero value, even when issuing errors and warnings.
...
We can change that by passing '-Wsparse-error' to 'sparse':
$ make SPARSE_FLAGS=-Wsparse-error change-table.sp
SP change-table.c
change-table.h:53:24: error: dubious one-bit signed bitfield
change-table.h:54:25: error: dubious one-bit signed bitfield
change-table.h:55:25: error: dubious one-bit signed bitfield
change-table.h:56:26: error: dubious one-bit signed bitfield
Makefile:2729: recipe for target 'change-table.sp' failed
make: *** [change-table.sp] Error 1
$ echo $?
2
$
Note that '-Wsparse-error' not only returns a non-zero exit code (1), but
it also changes a 'warning' into an 'error' (see above):Yes, I know :( The fact that, by default, sparse doesn't fail on errors is wanted (otherwise it would break the kernel compile). But that the only way to return an error is to use -Wsparse-error (which is supposed to replace GCC's -Werror) is a real problem. -- Luc