Re: [resend PATCH] coccinelle: Add devm_kmalloc_objs conversion script

From: Joe Perches

Date: Sun Nov 01 2026 - 20:06:15 EST


On 2026-11-01 15:51, Julia Lawall wrote:
On Sun, 1 Nov 2026, Joe Perches wrote:

Like commit bdc5071d7f7b ("coccinelle: Add kmalloc_objs conversion script")
with commit 1c7bbaeed110 ("coccinelle: kmalloc_obj: Remove default GFP_KERNEL arg")

Finds and converts sized devm_kmalloc-family of allocations into the typed
devm_kmalloc_obj-family of allocations.

Applied


Signed-off-by: Joe Perches <joe@xxxxxxxxxxx>
---

Maybe this might be useful to run and apply just prior to some -rc1

This script would change more than 8000 instances in more than
5000 files in Linus' current master.

$ spatch -D patch --very-quiet --cocci-file ./scripts/coccinelle/api/devm_kmalloc_objs.cocci \
--include-headers-for-types --all-includes --include-headers --keep-comments \
-I ./arch/x86/include -I ./arch/x86/include/generated -I ./include \
-I ./arch/x86/include/uapi -I ./arch/x86/include/generated/uapi -I ./include/uapi \
-I ./include/generated/uapi --include ./include/linux/compiler-version.h \
--include ./include/linux/kconfig.h .

I'm not sure that --include-headers-for-types is useful. That is useful
when there is an expression metavariable that is required to have a
particular type. I don't see that here. I also got around 5000 changes
in Linus's current master without using that argument. I didn't try it,
but I think --no-includes would thus be fine. --include-headers will get
the changes in the header files.

If the --keep comments argument is useful, it could be added to the
semantic patch, by putting #spatch --keep-comments at the top of the file.

Ok. Whatever is appropriate.

I just copied the command line from the one that applied the commits above.