Re: [Cocci] [PATCH v3] Coccinelle: Script to replace allocate and memset with zalloc functions
From: SF Markus Elfring
Date: Mon Aug 01 2016 - 07:57:39 EST
>> 1. Would it make sense to merge such SmPL rules into one
>> so that code duplication could be reduced a bit
>> in such a script?
>
> I think it would suffer in readability.
How do you think about the following SmPL script example?
@vz_combined
depends on patch && !context && !org && !report@
type T;
T* pointer;
+statement S;
expression express;
@@
pointer =
- vmalloc
+ vzalloc
(...);
if (!d)
S
-memset(d, 0, sizeof(
(
-T
|
-*(express)
)
-));
> Perhaps in performance as well.
I admit that I am unsure about the run-time characteristics
for my suggestion.
Regards,
Markus