Re: [Cocci] Matching function prototypes and casts
>> ( >> *setup_timer(>_timer@tl, \((_func)\| \) \(&\| \) _callback, \((_data)\| >> \) E); >> | >> *E->_timer@tl.function = \((_func)\| \) \(&\| \) _callback; >> ) > > No, it doesn't work, because \( \| \) matches an expression and there is > no empty expression. Will the Coccinelle software become able to generate the desired combination of casts and address-of operators anyhow automatically? Can the usage of optional items be expressed in a more convenient way here? Regards, Markus ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] Matching function prototypes and casts
> I had --no-includes in my .cocci. Would you like to transform also any header files by the mentioned approach? > More insane corner cases: Are you looking for further clarification there? Regards, Markus ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] Matching function prototypes and casts
On Fri, 25 Aug 2017, SF Markus Elfring wrote: > >> You try to search for variations of a function call and an assignment to > >> a data structure member. It seems that they differ then by the usage of a > >> cast > >> and the operator “&”. > >> How do you think about to express such search criteria in a succinct way > >> with > >> the help of the semantic patch language? > >> > >> I imagine that nested disjunctions or the SmPL operator “?” could be used > >> for your source code transformation approach. > > > > I don't know what you have in mind, > > Would the following design suggestion be usable? > > > @check_timer_function_usage@ > expression _callback, E; > struct timer_list tl; > identifier _timer; > type _func, _data; > @@ > > ( > *setup_timer(>_timer@tl, \((_func)\| \) \(&\| \) _callback, \((_data)\| \) > E); > | > *E->_timer@tl.function = \((_func)\| \) \(&\| \) _callback; > ) No, it doesn't work, because \( \| \) matches an expression and there is no empty expression. julia > > > I wonder that “E” should be passed twice to the shown function call. > > > > but ? only works on top-level terms (statements, loop headers, etc), not > > nested expressions. > > I assume that this functionality can occasionally be used more often. > > Regards, > Markus >___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] Matching function prototypes and casts
>> You try to search for variations of a function call and an assignment to >> a data structure member. It seems that they differ then by the usage of a >> cast >> and the operator “&”. >> How do you think about to express such search criteria in a succinct way with >> the help of the semantic patch language? >> >> I imagine that nested disjunctions or the SmPL operator “?” could be used >> for your source code transformation approach. > > I don't know what you have in mind, Would the following design suggestion be usable? @check_timer_function_usage@ expression _callback, E; struct timer_list tl; identifier _timer; type _func, _data; @@ ( *setup_timer(>_timer@tl, \((_func)\| \) \(&\| \) _callback, \((_data)\| \) E); | *E->_timer@tl.function = \((_func)\| \) \(&\| \) _callback; ) I wonder that “E” should be passed twice to the shown function call. > but ? only works on top-level terms (statements, loop headers, etc), not > nested expressions. I assume that this functionality can occasionally be used more often. Regards, Markus ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] Matching function prototypes and casts
On Fri, 25 Aug 2017, SF Markus Elfring wrote: > > ( > > -setup_timer(&_E->_timer@_e, _callback, _E); > > | > … > > -_E->_timer@_e.function = (_cast_func)&_callback; > > ) > > You try to search for variations of a function call and an assignment to > a data structure member. It seems that they differ then by the usage of a cast > and the operator “&”. > How do you think about to express such search criteria in a succinct way with > the help of the semantic patch language? > > I imagine that nested disjunctions or the SmPL operator “?” could be used > for your source code transformation approach. I don't know what you have in mind, but ? only works on top-level terms (statements, loop headers, etc), not nested expressions. julia > > Regards, > Markus > ___ > Cocci mailing list > Cocci@systeme.lip6.fr > https://systeme.lip6.fr/mailman/listinfo/cocci >___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci
Re: [Cocci] Matching function prototypes and casts
> ( > -setup_timer(&_E->_timer@_e, _callback, _E); > | … > -_E->_timer@_e.function = (_cast_func)&_callback; > ) You try to search for variations of a function call and an assignment to a data structure member. It seems that they differ then by the usage of a cast and the operator “&”. How do you think about to express such search criteria in a succinct way with the help of the semantic patch language? I imagine that nested disjunctions or the SmPL operator “?” could be used for your source code transformation approach. Regards, Markus ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci