- `UNUSEDIGNORE`: a `checksrc` inlined warning ignore was asked for but not
used, that is an ignore that should be removed or changed to get used.
+- `USESAFEFREE`: there was a `curlx_free(var)` call made right before assigning
+ NULL to `var`. We prefer replacing that with `curlx_safefree()`, which is
+ doing these two operations in a single call.
+
### Extended warnings
Some warnings are computationally expensive to perform, so they are turned off
'TRAILINGSPACE' => 'Trailing whitespace on the line',
'TYPEDEFSTRUCT' => 'typedefed struct',
'UNUSEDIGNORE' => 'a warning ignore was not used',
+ 'USESAFEFREE' => 'replace curlx_free() + NULL assignment with curlx_safefree()',
);
sub readskiplist {
my $l = "";
my $prep = 0;
my $prevp = 0;
+ my $prevfreeindent = "";
+ my $prevfreevar = "";
if($verbose) {
printf "Checking file: $file\n";
$line, length($1), $file, $ol, "no space before label");
}
+ if($prevfreevar ne "") {
+ if(rindex($l, "$prevfreeindent$prevfreevar = NULL;", 0) == 0) {
+ checkwarn("USESAFEFREE",
+ $line, length($prevfreeindent), $file, $ol,
+ "replace curlx_free() + NULL assignment with curlx_safefree()");
+ }
+ }
+ if($l) {
+ if($l =~ /^( *)curlx_free\(([^)]+)\);/) {
+ $prevfreeindent = $1;
+ $prevfreevar = $2;
+ }
+ else {
+ $prevfreeindent = "";
+ $prevfreevar = "";
+ }
+ }
+
# scan for use of banned functions
my $bl = $l;
again:
int d = impl->magicbad(1); /* member function always allowed */
int e = impl.magicbad(); /* member function always allowed */
+ curlx_free(ptr); /* two line
+ comment */
+ ptr = NULL; /* comment more */
+
/* comment does not end
</file>
./%LOGDIR/code1185.c:71:2: warning: // comment (CPPCOMMENTS)
// CPP comment ?
^
+./%LOGDIR/code1185.c:78:2: warning: replace curlx_free() + NULL assignment with curlx_safefree() (USESAFEFREE)
+ ptr = NULL; /* more comment */
+ ^
./%LOGDIR/code1185.c:1:1: error: Missing copyright statement (COPYRIGHT)
%SP
^
./%LOGDIR/code1185.c:1:1: error: Missing closing comment (OPENCOMMENT)
%SP
^
-checksrc: 3 errors and 42 warnings
+checksrc: 3 errors and 43 warnings
</stdout>
<errorcode>
5