[PATCH] coccinelle: check for casting malloc output

Tom Rini trini at konsulko.com
Sun Apr 26 13:27:24 CEST 2020


On Sun, Apr 19, 2020 at 11:07:34AM +0200, Heinrich Schuchardt wrote:

> 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 at gmx.de>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200426/2afcafab/attachment.sig>


More information about the U-Boot mailing list