[PATCH v3 00/36] remove unnecessary null checks

Thomas Monjalon thomas at monjalon.net
Sat Feb 12 12:09:37 CET 2022


09/02/2022 20:17, Stephen Hemminger:
> While working on a new driver, noticed that some drivers always call
> free routines (correct) and others conditionally call free routines
> if not null (redundant check).  The extra if(e != NULL) type check
> is unneeded and adds extra code.  Better to have all the code
> consistent.
> 
> The Linux kernel has automated this kind of fixup using coccinelle,
> and this patchset creates a coccinelle script to do the transformation;
> then has individual patches for each sub component.

There are probably more functions to check, as suggested by this command:
all=$(git grep -ho 'rte_.*_free' lib/**/rte_*.h | sed '/[( ]/d' | sort -u);\
checked=$(grep -o 'rte_.*_free' devtools/cocci/nullfree.cocci | sort -u);\
printf "$all\n$checked" | sort | uniq -u

Applied, thanks.




More information about the dev mailing list