[Cocci] Change function invocations argument

SF Markus Elfring elfring at users.sourceforge.net
Sun Dec 21 12:55:57 CET 2014


> @@ typedef long_u, uintmax_t; expression e1, e2, e3; @@
> 
>     put_bytes(
>         e1,
> (
> -       (long_u)(e2)
> |
> -       (long_u)e2
> )
> +       (uintmax_t)e2
>         ,
> (
> -       (int)(e3)
> +       (unsigned int)e3
> |
> -       (int)e3
> +       (unsigned int)e3
> |
>         e3
> )
>     )

Can it be that you need to fiddle with SmPL disjunctions a bit less here
because the metavariable type (or an isomorphism) will take care for
additional parentheses around the affected expressions?

How do you think about the applicability of the following approach?

@parameter_cast_replacement@
expression e1, e2, e3;
typedef long_u, uintmax_t;
@@
 put_bytes(e1,
-          (long_u)
+          (uintmax_t)
           e2,
(
-          (int)
+          (unsigned int)
           e3
|
           e3
)
          )

Regards,
Markus


More information about the Cocci mailing list