SV: [Cocci] How to match &(ttyname(0))[5]

Julia Lawall julia at diku.dk
Fri Nov 27 15:30:27 CET 2009


Actually, your patch worked fine for me.  Although in the exact patch you 
sent there was no indication of a transformation, or a *, so that by 
itself didn't do anything.

julia


On Fri, 27 Nov 2009, Andreas.Aaen at tieto.com wrote:

> Sure:
> ----------------------------------------------
> #include <unistd.h>
> #include <stdio.h>
> int main()
> {
>  char filename[100];
>  sprintf (filename, "/tmp/cnf.%s", &(ttyname(0))[5]) ;
>  printf(filename);
> }
> ---------------------------------------------
> ________________________________________
> Fra: Julia Lawall [julia at diku.dk]
> Sendt: 27. november 2009 10:11
> Til: Aaen Andreas
> Cc: cocci at diku.dk
> Emne: Re: [Cocci] How to match &(ttyname(0))[5]
> 
> Could you send a small test file (.c)?
> 
> thanks,
> julia
> 
> 
> 
> On Fri, 27 Nov 2009, Andreas.Aaen at tieto.com wrote:
> 
> > Hi,
> >
> > I an porting an application from one Unix flavor to another. I have found expressions in the code like this:
> >
> > &(ttyname(0))[5]
> >
> > In some flavors of Unix this might give you a unique number, but it depend very much of the naming convention, so I wan't to find all these.
> > How do I find this?
> >
> > $$
> > expression E1;
> > $$
> > ttyname(E1)
> >
> > does find all uses of ttyname, but
> >
> > $$
> > expression E1;
> > $$
> > &(ttyname(E1))[5]
> >
> > doesn't match anything
> > What did I express wrongly in Coccinelle?
> >
> > Regards
> > Andreas Bach Aaen
> >


More information about the Cocci mailing list