lkml.org 
[lkml]   [2016]   [Aug]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [Cocci] [PATCH v3] Coccinelle: Script to replace allocate and memset with zalloc functions


On Mon, 1 Aug 2016, SF Markus Elfring wrote:

> >> 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)
> )
> -));

OK, I thought you meant to make a big disjunctions for all of the before
and after functions. This is a little better because it is bounded in
size. But I don't understand why you have introduced the variable
express. Normally one wants the cleared space to be the allocated size,
which is normally the size of *pointer.

The performance issue is that disjunctions on expressions, eg (A | B), are
implemented as (A | (!A & B)), ie with a negation of all the previous
options &d with each option. So it is better to avoid very large
disjunctions on expressions.

julia


>
>
> > Perhaps in performance as well.
>
> I admit that I am unsure about the run-time characteristics
> for my suggestion.
>
> Regards,
> Markus
>

\
 
 \ /
  Last update: 2016-08-01 14:41    [W:0.049 / U:0.312 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site