On Sat, 8 Aug 2015, SF Markus Elfring wrote:
> > I have tried the following small SmPL script
> >
> > @show_designated_initialisers@
> > identifier allocation, element, structure_type, structure_var;
> > @@
> > <+...
> > *struct structure_type structure_var = { ..., .element = allocation(...),
> > ... };
> > ...+>
> >
> >
> > on this
> >
> >
> > char* get_default_message(short selection)
> > {
> > static char xyz[123];
> >
> > switch (selection)
> > {
> > case 1:
> > strcpy(xyz, "Test");
> > default:
> > strcpy(xyz, "working");
> > }
> > return xyz;
> > }
> >
> > static unsigned long my_counter = 0;
> >
> > static struct my_string
> > {
> > unsigned int length;
> > char* text;
> > } message = { .text = get_default_message(1), .length = 123 };
Actually, I don't see where you expect your rule to match your code. I
don't see the point of including the function withe the switch and the
declaration of my-counter in the example at all. The only case where
there is any hope of a match is in the declaration of the my_string
strcuture, but that declaration doesn't have the same form as your
semantic patch rule. Your code specifies the types of the fields at the
same time, which is not done in the pattern.
julia
> >
> >
> > source code example.
> >
> >
> > elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch.opt -sp-file
> > show_designated_initialisers1.cocci designated_initialiser1.c
> > init_defs_builtins: /usr/local/lib/coccinelle/standard.h
> > HANDLING: designated_initialiser1.c
> >
> >
> > Unfortunately, I do not see a generated patch there.
> > How should I improve my approach for the expected analysis result?
>
> How is the status for the support of data processing for designated
> initialisers
> with the semantic patch language?
>
> Regards,
> Markus
> _______________________________________________
> Cocci mailing list
> [email protected]
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci