
On Wed, Mar 07, 2018 at 02:57:19AM +0100, Heinrich Schuchardt wrote:
kmerr: verify that malloc and calloc are followed by a check to verify that we are not out of memory.
badzero: Compare pointer-typed values to NULL rather than 0
Both checks are copied from the Linux kernel archive.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
scripts/coccinelle/null/badzero.cocci | 238 ++++++++++++++++++++++++++++++++++ scripts/coccinelle/null/kmerr.cocci | 72 ++++++++++ 2 files changed, 310 insertions(+) create mode 100644 scripts/coccinelle/null/badzero.cocci create mode 100644 scripts/coccinelle/null/kmerr.cocci
diff --git a/scripts/coccinelle/null/badzero.cocci b/scripts/coccinelle/null/badzero.cocci new file mode 100644 index 0000000000..f597c8007b --- /dev/null +++ b/scripts/coccinelle/null/badzero.cocci @@ -0,0 +1,238 @@ +/// Compare pointer-typed values to NULL rather than 0 +/// +//# This makes an effort to choose between !x and x == NULL. !x is used +//# if it has previously been used with the function used to initialize x. +//# This relies on type information. More type information can be obtained +//# using the option -all_includes and the option -I to specify an +//# include path. +// +// Confidence: High +// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. +// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. +// URL: http://coccinelle.lip6.fr/ +// Requires: 1.0.0 +// Options:
We should probably be adding an SPDX tag here. Or, adding one in Linux and pulling it in then? Thanks!