Re: [Cocci] Matching function prototypes and casts

2017-08-23 Thread Julia Lawall
> > For me it works. Do you have the latest version of Coccinelle from > > github? I used the option --all-includes. > > Ah-ha! Thank you. :) I had --no-includes in my .cocci. :) >From a performance point of view, you might want to do what you can with --no-includes first. It will then only be

Re: [Cocci] Matching function prototypes and casts

2017-08-23 Thread Kees Cook
On Wed, Aug 23, 2017 at 2:19 PM, Julia Lawall wrote: > > > On Wed, 23 Aug 2017, Kees Cook wrote: > >> I think I'm getting closer. Here are some specific examples that don't >> seem to work: >> >> ---match_callback.cocci--- >> virtual patch >> >> @match_timer_function_usage

Re: [Cocci] Matching function prototypes and casts

2017-08-23 Thread Kees Cook
I think I'm getting closer. Here are some specific examples that don't seem to work: ---match_callback.cocci--- virtual patch @match_timer_function_usage depends on patch@ expression _E; struct timer_list _e; identifier _timer; identifier _callback; type _cast_func, _cast_data; @@ (

Re: [Cocci] [PATCH] coccinelle: Improve setup_timer.cocci matching

2017-08-23 Thread Kees Cook
On Wed, Aug 23, 2017 at 6:13 AM, Julia Lawall wrote: > > > On Tue, 22 Aug 2017, Kees Cook wrote: > >> This improves the patch mode of setup_timer.cocci. Several patterns were >> missing: >> - assignments-before-init_timer() cases >> - limiting the .data case removal to the

Re: [Cocci] parsing of C code

2017-08-23 Thread Julia Lawall
On Wed, 23 Aug 2017, Derek M Jones wrote: > Julia, > > > I don't think that is what it is. The declarations are eg: > > > > static inline __printf(2, 3) > > void _dev_info(const struct device *dev, const char *fmt, ...) > > {} > > > > I guess that the whole first line is part of the

Re: [Cocci] parsing of C code

2017-08-23 Thread Derek M Jones
Julia, I don't think that is what it is. The declarations are eg: static inline __printf(2, 3) void _dev_info(const struct device *dev, const char *fmt, ...) {} I guess that the whole first line is part of the declaration of _dev_info, but Coccinelle can't cope with the __printf(2, 3).

Re: [Cocci] parsing of C code

2017-08-23 Thread Julia Lawall
On Wed, 23 Aug 2017, Derek M Jones wrote: > Julia, > > > The Linux kernel has some declarations like > > > > type fn(a1, a2) > > > with no trailing ; followed by a function definition. This gives a parse > > error on a1. In the previous version, Coccinelle was able to recover an > > The K

Re: [Cocci] Comparing statement lists with SmPL

2017-08-23 Thread SF Markus Elfring
>> How should the source code search be improved further here? > > If you like the results from the second case, what more do you want? * There are also several questionable transformation suggestions generated besides the usable ones. * Will answers belong also to the topic “Get the

Re: [Cocci] Comparing statement lists with SmPL

2017-08-23 Thread SF Markus Elfring
> You would need when any on the ... Otherwise, it will not match anything > (perhaps declarations). The s1 after is precludes matching any statement. > Likewise in the next if. The suggested variant does still not work in the way I would expect it. @duplicated_code@ identifier work; statement

Re: [Cocci] Comparing statement lists with SmPL

2017-08-23 Thread SF Markus Elfring
> I have tried another variant out for a source code analysis. Does the following SmPL script variant make sense? @duplicated_code@ identifier work; statement s1, s2; type T; @@ T work(...) { ... when any *if ((...) < 0) *{ ... * s1 * s2 *} <+... *if ((...) < 0) *{ ... * s1 *

[Cocci] [PATCH] Coccinelle: setup_timer: improve messages from setup_timer

2017-08-23 Thread Julia Lawall
Allow messages about multiple timers. Signed-off-by: Julia Lawall --- scripts/coccinelle/api/setup_timer.cocci | 15 ++- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/scripts/coccinelle/api/setup_timer.cocci

Re: [Cocci] [PATCH] coccinelle: Improve setup_timer.cocci matching

2017-08-23 Thread Julia Lawall
On Tue, 22 Aug 2017, Kees Cook wrote: > This improves the patch mode of setup_timer.cocci. Several patterns were > missing: > - assignments-before-init_timer() cases > - limiting the .data case removal to the struct timer_list instance > - handling calls by dereference (timer->field vs

Re: [Cocci] Matching function prototypes and casts

2017-08-23 Thread Julia Lawall
On Tue, 22 Aug 2017, Kees Cook wrote: > Hi, > > I'm working on a large type conversion for struct timer_list, and > it'll require changing all of the callback prototypes and changing > logic at their start. For example, if I start with this: > > > void primary_callback(unsigned long arg); >

Re: [Cocci] parsing of C code

2017-08-23 Thread Julia Lawall
On Tue, 22 Aug 2017, Derek M Jones wrote: > Julia, > > > 1. More aggressive inclusion of header files, combined with caching of > > header files. Now if there is only one occurrence of a header file with a > > Caching can be dangerous because macros may be defined differently > for different

Re: [Cocci] parsing of C code

2017-08-23 Thread Julia Lawall
On Tue, 22 Aug 2017, Derek M Jones wrote: > Julia, > > > 1. More aggressive inclusion of header files, combined with caching of > > header files. Now if there is only one occurrence of a header file with a > > Caching can be dangerous because macros may be defined differently > for different