]> git.baikalelectronics.ru Git - uboot.git/commit
coccinelle: check for casting malloc output
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Sun, 19 Apr 2020 09:07:34 +0000 (11:07 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 24 Apr 2020 20:40:09 +0000 (16:40 -0400)
commit864ec1377f358f54ad4813471f828eab6326d106
treeabe4255ab3c9f52cb753a79ff9dcea995887446a
parent82338f9d49850043cb91193a7bb80cdf1711d3d2
coccinelle: check for casting malloc output

Casting the (void *) output of memory allocation functions before
assignment like in

sata->cmd_hdr_tbl_offset = (void *)malloc(length + align);

is useless.

Adopt the Linux kernel script
scripts/coccinelle/api/alloc/alloc_cast.cocci.

Now 'make coccicheck' generates warnings like:

./drivers/ata/fsl_sata.c:143:29-33:
WARNING: casting value returned by memory allocation function
to (void *) is useless.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
scripts/coccinelle/api/alloc/alloc_cast.cocci [new file with mode: 0644]