* [Cocci] Have coccinelle follow typedef ?
@ 2013-03-19 16:16 Eric Leblond
2013-03-19 17:18 ` Julia Lawall
0 siblings, 1 reply; 3+ messages in thread
From: Eric Leblond @ 2013-03-19 16:16 UTC (permalink / raw)
To: cocci
Hello,
I've got the following construction in a code:
typedef struct Packet_ {
struct Flow_ * flow;
} Packet;
and in an other include file:
typedef struct Flow_ {
...
} Flow;
My problem here is that if p is a Packet then p->flow is a Flow at least
from a developer point of view. But coccinelle is not detecting the
match "Flow f" do not match on a "p->flow".
I've thought about adding a new isomorphism to solve this but I don't
like the idea...
How could I fix this issue ?
BR,
--
Eric Leblond <eric@regit.org>
Blog: https://home.regit.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Cocci] Have coccinelle follow typedef ?
2013-03-19 16:16 [Cocci] Have coccinelle follow typedef ? Eric Leblond
@ 2013-03-19 17:18 ` Julia Lawall
2013-03-19 17:53 ` Eric Leblond
0 siblings, 1 reply; 3+ messages in thread
From: Julia Lawall @ 2013-03-19 17:18 UTC (permalink / raw)
To: cocci
On Tue, 19 Mar 2013, Eric Leblond wrote:
> Hello,
>
> I've got the following construction in a code:
> typedef struct Packet_ {
> struct Flow_ * flow;
> } Packet;
> and in an other include file:
> typedef struct Flow_ {
> ...
> } Flow;
>
> My problem here is that if p is a Packet then p->flow is a Flow at least
> from a developer point of view. But coccinelle is not detecting the
> match "Flow f" do not match on a "p->flow".
>
> I've thought about adding a new isomorphism to solve this but I don't
> like the idea...
>
> How could I fix this issue ?
--all-includes?
I thik the type inferencer should be aware of typedefs, if it sees the
definition.
julia
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Cocci] Have coccinelle follow typedef ?
2013-03-19 17:18 ` Julia Lawall
@ 2013-03-19 17:53 ` Eric Leblond
0 siblings, 0 replies; 3+ messages in thread
From: Eric Leblond @ 2013-03-19 17:53 UTC (permalink / raw)
To: cocci
Hello,
On Tue, 2013-03-19 at 18:18 +0100, Julia Lawall wrote:
>
> On Tue, 19 Mar 2013, Eric Leblond wrote:
>
> > Hello,
> >
> > I've got the following construction in a code:
> > typedef struct Packet_ {
> > struct Flow_ * flow;
> > } Packet;
> > and in an other include file:
> > typedef struct Flow_ {
> > ...
> > } Flow;
> >
> > My problem here is that if p is a Packet then p->flow is a Flow at least
> > from a developer point of view. But coccinelle is not detecting the
> > match "Flow f" do not match on a "p->flow".
> >
> > I've thought about adding a new isomorphism to solve this but I don't
> > like the idea...
> >
> > How could I fix this issue ?
>
> --all-includes?
>
> I thik the type inferencer should be aware of typedefs, if it sees the
> definition.
Thanks a lot for your answer but it does not work.
I've added a direct inclusion of file definition in my source file to be
sure include containing definitions will be found by coccinelle.
When adding --recurse-includes and/or --all-includes it is able to find
that p->flow is a "struct Flow_ *" but it does not inference it as a
Flow:
Running: spatch --recursive-includes --all-includes -sp_file /tmp/tmpQ678Iv.cocci detect-engine-tag.c.
init_defs_builtins: /usr/share/coccinelle/standard.h
HANDLING: detect-engine-tag.c
detect-engine-tag.c:241 (Flow *f): if (f->tag_list == NULL)
detect-engine-tag.c:246 (Flow *f): DetectTagDataEntry *iter = f->tag_list;
with /tmp/tmpQ678Iv.cocci being
@init@
Flow *p;
Flow ps;
position p1;
@@
(
p at p1->tag_list
|
ps at p1.tag_list
)
@Some python code to print p1@
If I look for "struct Flow_" (simple substitution in the @init@), I've
got:
Running: spatch --recursive-includes --all-includes -sp_file /tmp/tmpmSk2Cm.cocci detect-engine-tag.c.
init_defs_builtins: /usr/share/coccinelle/standard.h
HANDLING: detect-engine-tag.c
detect-engine-tag.c:121 (struct Flow_ *p->flow): if (p->flow->tag_list != NULL) {
detect-engine-tag.c:122 (struct Flow_ *p->flow): iter = p->flow->tag_list;
with p being a Packet. So the definition of Packet has been found.
I've been trying this latest coccinelle git.
BR,
--
Eric Leblond <eric@regit.org>
Blog: https://home.regit.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-03-19 17:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-19 16:16 [Cocci] Have coccinelle follow typedef ? Eric Leblond
2013-03-19 17:18 ` Julia Lawall
2013-03-19 17:53 ` Eric Leblond
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.