Re: [Cocci] Coccinelle: Length/Size of char array?

2021-08-02 Thread Julia Lawall
On Mon, 2 Aug 2021, Joe Perches wrote: > On Mon, 2021-08-02 at 19:35 +0200, Julia Lawall wrote: > > > > On Mon, 2 Aug 2021, Joe Perches wrote: > > > > > Is it possible to determine the length of a matched char array and use > > > the length in a test?

Re: [Cocci] Coccinelle: Length/Size of char array?

2021-08-02 Thread Julia Lawall
On Mon, 2 Aug 2021, Joe Perches wrote: > Is it possible to determine the length of a matched char array and use > the length in a test? > > For instance, add something like a test to show only the instances > where a src buffer overruns a dest buffer. > > void foo(void) > { > char

Re: [Cocci] [PATCH] scripts: coccinelle: allow list_entry_is_head() to use pos

2021-07-30 Thread Julia Lawall
On Fri, 30 Jul 2021, Daniel Thompson wrote: > Currently use_after_iter.cocci generates false positives for code of the > following form: > ~~~ > list_for_each_entry(d, >irq_list, node) { > if (irq == d->irq) > break; > } > > if

Re: [Cocci] how to make substitutions at the end of the function, vs. the end of each block ?

2021-07-23 Thread Julia Lawall
Here is another attempt: @initialize:ocaml@ @@ let check p = let p = List.hd p in p.line_end = p.current_element_line_end @ detect_func @ identifier CLI_FN, AVM, AIN, ACMD; fresh identifier LAIN = "line_" ## AIN; expression ERR, exp; statement S1; typedef clib_error_t, vlib_main_t,

Re: [Cocci] how to make substitutions at the end of the function, vs. the end of each block ?

2021-07-23 Thread Julia Lawall
> yourtch@ayourtch-lnx:~/cocci$ diff -c patch-old.cocci patch-new.cocci > *** patch-old.cocci 2021-07-22 22:41:19.516957878 +0200 > --- patch-new.cocci 2021-07-22 22:41:52.625184341 +0200 > *** > *** 3,8 > --- 3,9 > fresh identifier LAIN = "line_" ## AIN; > >

Re: [Cocci] how to make substitutions at the end of the function, vs. the end of each block ?

2021-07-23 Thread Julia Lawall
> I missed the fact that the "return ERR" were actually not replaced on > this example at all, This is because there are no occurrences of return ERR; in your code. Probably you expected ERR to be a metavariable, but it's not. Actually, fully capitalizing your metavariables is not a good idea.

Re: [Cocci] how to make substitutions at the end of the function, vs. the end of each block ?

2021-07-22 Thread Julia Lawall
On Thu, 22 Jul 2021, Andrew  Yourtchenko wrote: > Hi all, > > I work on the VPP project (http://fd.io/ - open source software > dataplane), and tried to use coccinelle to make a relatively > non-trivial change > as in the mail https://lists.fd.io/g/vpp-dev/message/17532 - it seemed > to be a

Re: [Cocci] cocci script to convert linux-kernel allocs with BITS_TO_LONGS to bitmap_alloc

2021-07-14 Thread Julia Lawall
On Tue, 13 Jul 2021, Joe Perches wrote: > On Tue, 2021-07-13 at 23:33 +0200, Julia Lawall wrote: > > > > On Fri, 9 Jul 2021, Joe Perches wrote: > > > > > Here is a cocci script to convert various types of bitmap allocations > > > > > that use B

Re: [Cocci] cocci script to convert linux-kernel allocs with BITS_TO_LONGS to bitmap_alloc

2021-07-13 Thread Julia Lawall
On Sat, 10 Jul 2021, Joe Perches wrote: > On Sat, 2021-07-10 at 21:50 +0200, Julia Lawall wrote: > > On Fri, 9 Jul 2021, Joe Perches wrote: > > > > > Here is a cocci script to convert various types of bitmap allocations > > > that use BITS_TO_LONGS to the mo

Re: [Cocci] cocci script to convert linux-kernel allocs with BITS_TO_LONGS to bitmap_alloc

2021-07-10 Thread Julia Lawall
On Sat, 10 Jul 2021, Joe Perches wrote: > On Sat, 2021-07-10 at 21:50 +0200, Julia Lawall wrote: > > On Fri, 9 Jul 2021, Joe Perches wrote: > > > > > Here is a cocci script to convert various types of bitmap allocations > > > that use BITS_TO_LONGS to the mo

Re: [Cocci] cocci script to convert linux-kernel allocs with BITS_TO_LONGS to bitmap_alloc

2021-07-10 Thread Julia Lawall
On Fri, 9 Jul 2021, Joe Perches wrote: > Here is a cocci script to convert various types of bitmap allocations > that use BITS_TO_LONGS to the more typical bitmap_alloc functions. > > Perhaps something like it could be added to scripts/coccinelle. > The diff produced by the script is also

Re: [Cocci] [PATCH 0/2] Add "use-patchdiff" option

2021-07-01 Thread Julia Lawall
On Fri, 2 Jul 2021, Sumera Priyadarsini wrote: > On Wed, May 26, 2021 at 10:13 PM Markus Elfring wrote: > > > > > This patchset adds a feature to enable Coccinelle > > > to only check all those files in a directory which were > > > modified. It parses all the files obtained from the > > >

Re: [Cocci] [PATCH] Coccinelle: Update and rename api/alloc/pci_free_consistent.cocci

2021-06-26 Thread Julia Lawall
On Wed, 16 Jun 2021, Christophe JAILLET wrote: > 'pci_alloc_consistent()' is about to be removed from the kernel. > It is now more useful to check for dma_alloc_coherent/dma_free_coherent. > > So change the script accordingly and rename it. There also seem to be a lot of false positives,

Re: [Cocci] [PATCH] Coccinelle: Update and rename api/alloc/pci_free_consistent.cocci

2021-06-26 Thread Julia Lawall
On Wed, 16 Jun 2021, Christophe JAILLET wrote: > 'pci_alloc_consistent()' is about to be removed from the kernel. > It is now more useful to check for dma_alloc_coherent/dma_free_coherent. dma_alloc_coherent has four arguments, and in the script there are only three. Is the number of

Re: [Cocci] Adding a newline after a variable definition

2021-06-23 Thread Julia Lawall
On Wed, 23 Jun 2021, Fuad Tabba wrote: > Hi, > > I have a semantic patch that inserts a new variable definition into a > function. I would like it if that variable definition is the only one > in the function, then it should add a new line to separate the > definition from following statements

Re: [Cocci] struct type renaming in the absence of certain function calls on members

2021-06-05 Thread Julia Lawall
On Sat, 5 Jun 2021, Jason A. Donenfeld wrote: > That makes sense. Thank you so much for your help. Committed here (and > credited you as co-author): > https://git.zx2c4.com/wireguard-freebsd/commit/?id=b13579613ffcbe56c28df79972a74025007a85b7 Cool. Thanks :) julia

Re: [Cocci] struct type renaming in the absence of certain function calls on members

2021-06-05 Thread Julia Lawall
On Sat, 5 Jun 2021, Jason A. Donenfeld wrote: > Thanks! That seems to be it indeed. Interestingly, including the > actual path to the real headers with -I didn't fix the issue. Most of the time, Coccinelle doesn't use macro definitions. The -I could have been useful for figuring out some

Re: [Cocci] struct type renaming in the absence of certain function calls on members

2021-06-05 Thread Julia Lawall
Try making a file def.h: #define CK_LIST_HEAD(x,y) int #define CK_LIST_ENTRY(x) int and then add to your command line --macro-file def.h There seem to be a few other such macros that are needed. Unrelatedly, you can also add --very-quiet to the command line, to have a less verbose output.

Re: [Cocci] struct type renaming in the absence of certain function calls on members

2021-06-05 Thread Julia Lawall
On Sat, 5 Jun 2021, Jason A. Donenfeld wrote: > Hi Julia, > > Holy mackerel, that's amazing. Thank you so much! Very fancy embedding > the ocaml in there, and just using a hash table. Neat idea. > > I'm running it (well, a modified version, pasted below) on a codebase > and finding that it

Re: [Cocci] struct type renaming in the absence of certain function calls on members

2021-06-05 Thread Julia Lawall
On Sat, 5 Jun 2021, Jason A. Donenfeld wrote: > Hi Julia, > > Holy mackerel, that's amazing. Thank you so much! Very fancy embedding > the ocaml in there, and just using a hash table. Neat idea. > > I'm running it (well, a modified version, pasted below) on a codebase > and finding that it

Re: [Cocci] struct type renaming in the absence of certain function calls on members

2021-06-05 Thread Julia Lawall
On Sat, 5 Jun 2021, Jason A. Donenfeld wrote: > Hi, > > I'm trying to write a spatch rule that has some inversion logic for a > given struct member, but I'm struggling to express this in SmPL. I'm > also a bit of a coccinelle novice, however. Specifically, I'm trying > to express: > > For all

Re: [Cocci] No coccicheck target

2021-06-04 Thread Julia Lawall
On Fri, 4 Jun 2021, Jonas Schrottenbaum wrote: > Hello,  > i'm currently trying to check out coccinelle and already could apply a simple > semantic patch to a small C program with the spatch command. > > Please excuse me, but i'm quite a beginner in this field.   > > I read on this page, about 

Re: [Cocci] Adding a line to a function after all variable declarations

2021-05-27 Thread Julia Lawall
On Thu, 27 May 2021, Fuad Tabba wrote: > On Thu, May 27, 2021 at 12:44 PM Julia Lawall wrote: > > > > > @@ > > > expression a, b; > > > identifier vcpu; > > > fresh identifier vcpu_ctxt = vcpu ## "_ctxt"; >

Re: [Cocci] Adding a line to a function after all variable declarations

2021-05-27 Thread Julia Lawall
> @@ > expression a, b; > identifier vcpu; > fresh identifier vcpu_ctxt = vcpu ## "_ctxt"; > iterator name kvm_for_each_vcpu; > identifier fc; > @@ > kvm_for_each_vcpu(a, vcpu, b) > { > /* hop over any declarations */ > + vcpu_ctxt = >arch.ctxt; > <+... > fc(..., vcpu, ...) > ...+> > } > > So

Re: [Cocci] Adding a line to a function after all variable declarations

2021-05-27 Thread Julia Lawall
On Thu, 27 May 2021, Julia Lawall wrote: > > > On Thu, 27 May 2021, Fuad Tabba wrote: > > > Hi, > > > > I'm trying to write a semantic patch that would add a new line to a > > function, but would like that line to come after all local variables > >

Re: [Cocci] Adding a line to a function after all variable declarations

2021-05-27 Thread Julia Lawall
On Thu, 27 May 2021, Fuad Tabba wrote: > Hi, > > I'm trying to write a semantic patch that would add a new line to a > function, but would like that line to come after all local variables > (if any) have been declared. For example (distilled from what I am > actually trying to accomplish): > >

Re: [Cocci] [PATCH] scripts: coccicheck: fix troubles on non-English builds

2021-05-18 Thread Julia Lawall
On Tue, 18 May 2021, Mauro Carvalho Chehab wrote: > When LANG is not set to English, the logic which checks the > number of CPUs fail, as the messages can be localized, and > the logic at: > > THREADS_PER_CORE=$(lscpu | grep "Thread(s) per core: " | tr -cd > "[:digit:]") > > will not get

[Cocci] [PATCH v6] coccinelle: api: semantic patch to use pm_runtime_resume_and_get

2021-05-17 Thread Julia Lawall
use it aolso deals with the cases where {}s need to be removed. pm_runtime_resume_and_get was introduced in commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") Signed-off-by: Julia Lawall Acked-by: Rafael J. Wysocki --- v6: don't touch cod

Re: [Cocci] [PATCH v5] coccinelle: api: semantic patch to use pm_runtime_resume_and_get

2021-05-16 Thread Julia Lawall
On Wed, 5 May 2021, Mauro Carvalho Chehab wrote: > Hi Julia, > > Em Thu, 29 Apr 2021 19:43:43 +0200 > Julia Lawall escreveu: > > > pm_runtime_get_sync keeps a reference count on failure, which can lead > > to leaks. pm_runtime_resume_and_get drops the reference co

[Cocci] [PATCH v4] coccinelle: api: semantic patch to use pm_runtime_resume_and_get

2021-04-29 Thread Julia Lawall
usage counter") Signed-off-by: Julia Lawall Acked-by: Rafael J. Wysocki --- v5: print a message with the new function name, as suggested by Markus Elfring v4: s/pm_runtime_resume_and_get/pm_runtime_put_noidle/ as noted by John Hovold v3: add the people who signed off on commit dd8088d5a896, expa

[Cocci] [PATCH v4] coccinelle: api: semantic patch to use pm_runtime_resume_and_get

2021-04-27 Thread Julia Lawall
usage counter") Signed-off-by: Julia Lawall Acked-by: Rafael J. Wysocki --- v4: s/pm_runtime_resume_and_get/pm_runtime_put_noidle/ as noted by John Hovold v3: add the people who signed off on commit dd8088d5a896, expand the log message v2: better keyword scripts/cocc

[Cocci] [PATCH v3] coccinelle: api: semantic patch to use pm_runtime_resume_and_get

2021-04-27 Thread Julia Lawall
usage counter") Signed-off-by: Julia Lawall --- v3: add the people who signed off on commit dd8088d5a896, expand the log message v2: better keyword scripts/coccinelle/api/pm_runtime_resume_and_get.cocci | 153 + 1 file changed, 153 insertions(+) diff --git a/scripts/cocc

Re: [Cocci] [PATCH v2] coccinelle: api: semantic patch to use pm_runtime_resume_and_get

2021-04-27 Thread Julia Lawall
On Tue, 27 Apr 2021, Johan Hovold wrote: > On Mon, Apr 26, 2021 at 08:54:04PM +0200, Julia Lawall wrote: > > pm_runtime_get_sync keeps a reference count on failure, which can lead > > to leaks. pm_runtime_resume_and_get drops the reference count in the > > failure

[Cocci] [PATCH v2] coccinelle: api: semantic patch to use pm_runtime_resume_and_get

2021-04-26 Thread Julia Lawall
to be needed in the failure case. pm_runtime_resume_and_get was introduced in commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") Signed-off-by: Julia Lawall --- v2: better keyword scripts/coccinelle/api/pm_runtime_resume_and_get.co

[Cocci] [PATCH] coccinelle: api: semantic patch to use pm_runtime_resume_and_get

2021-04-25 Thread Julia Lawall
to be needed in the failure case. pm_runtime_resume_and_get was introduced in commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") Signed-off-by: Julia Lawall --- scripts/coccinelle/api/pm_runtime_resume_and_get.cocci | 153 +++

Re: [Cocci] [PATCH] coccinelle: irqf_oneshot: reduce the severity due to false positives

2021-04-23 Thread Julia Lawall
On Fri, 23 Apr 2021, Krzysztof Kozlowski wrote: > The IRQF_ONESHOT should be present for threaded IRQ using default > primary handler. However intetrupt of many child devices, e.g. children > of MFD, is nested thus the IRQF_ONESHOT is not needed. The coccinelle > message about error misleads

Re: [Cocci] getting rid of implicit boolean expressions

2021-04-21 Thread Julia Lawall
On Wed, 21 Apr 2021, Akos Pasztory wrote: > Hi, > > I'm trying do the following kind of transformations: > >  int x, y; >  char *p; >  bool b, c; > > -b = x || !y; > +b = (x != 0) || (y == 0); > > -c = !p; > +c = (p == NULL); > > -if (x & 3) > +if ((x & 3) != 0) >  f(); > // etc > > That is:

Re: [Cocci] [PATCH] Fix parse error in presence of symbols named far

2021-04-21 Thread Julia Lawall
On Wed, 21 Apr 2021, Fuad Tabba wrote: > Hi, > > I just started using Coccinelle yesterday, and I can already see > it saving me a lot of time and agony. Thank you. > > I ran into a problem, and I think that this patch might fix it, > hopefully without causing other problems. I did some sanity

[Cocci] [PATCH] Coccinelle: drop context *s

2021-04-19 Thread Julia Lawall
Context mode is not supported, so the *s are just confusing to people who use the rule outside of make coccicheck. So, drop the *s. Fixes: 6dd9379e8f32 ("coccinelle: also catch kzfree() issues") Reported-by: Fabio M. De Francesco Signed-off-by: Julia Lawall --- scripts/cocci

Re: [Cocci] changing of_get_mac_address() to pass a buffer

2021-04-05 Thread Julia Lawall
On Mon, 5 Apr 2021, Michael Walle wrote: > Hi Mansour, > > Am 2021-04-04 19:48, schrieb Mansour Moufid: > > On Thu, Apr 1, 2021 at 4:13 AM Michael Walle wrote: > > > > > > Hi, > > > > > > so first I need to say I've never used coccinelle before, > > > so please bear with me ;) > > > > > > To

Re: [Cocci] Checking support for compound expressions (according to #define directives)

2021-04-05 Thread Julia Lawall
On Mon, 5 Apr 2021, Markus Elfring wrote: > >> I would like to avoid the repetition of parsing efforts as much as > >> possible. > >> Under which circumstances can replacement lists be taken better into > >> account? > > > > Why does my suggestion involve a repetition of parsing effort? > >

Re: [Cocci] Checking support for compound expressions (according to #define directives)

2021-04-05 Thread Julia Lawall
On Mon, 5 Apr 2021, Markus Elfring wrote: > >> @display@ > >> identifier i =~ "^(?:[A-Z]+_){3,3}[A-Z]+", x; > >> constant c =~ "\""; > >> @@ > >> *#define i x c > >> > >> > >> elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch --parse-cocci > >> show_define_usage6.cocci > >> … > >> minus:

Re: [Cocci] Checking support for compound expressions (according to #define directives)

2021-04-05 Thread Julia Lawall
On Mon, 5 Apr 2021, Markus Elfring wrote: > > Thanks for the simpler examples. > > Would you like to support another search pattern by the means of > the semantic patch language? > > > @display@ > identifier i =~ "^(?:[A-Z]+_){3,3}[A-Z]+", x; > constant c =~ "\""; > @@ > *#define i x c > > >

Re: [Cocci] changing of_get_mac_address() to pass a buffer

2021-04-04 Thread Julia Lawall
On Sun, 4 Apr 2021, Mansour Moufid wrote: > On Thu, Apr 1, 2021 at 4:13 AM Michael Walle wrote: > > > > Hi, > > > > so first I need to say I've never used coccinelle before, > > so please bear with me ;) > > > > To make of_get_mac_address() work with DSA ports (and a nvmem > > provider) I'd

Re: [Cocci] [PATCH v3] coccinelle: misc: add swap script

2021-04-04 Thread Julia Lawall
On Sun, 28 Mar 2021, Denis Efremov wrote: > Ping? Applied. Thanks. > > On 3/5/21 1:09 PM, Denis Efremov wrote: > > Check for opencoded swap() implementation. > > > > Signed-off-by: Denis Efremov > > --- > > Changes in v2: > > - additional patch rule to drop excessive {} > > - fix

Re: [Cocci] Excluding quotes from strings of #define directives

2021-04-04 Thread Julia Lawall
On Sun, 4 Apr 2021, Markus Elfring wrote: > >> I hoped that the specified constraint for the metavariable “e” would mean > >> that expressions which contain a double quotation character should be > >> excluded > >> for my source code analysis approach. > >> Would you like to check the observed

Re: [Cocci] Excluding quotes from strings of #define directives

2021-04-04 Thread Julia Lawall
On Sun, 4 Apr 2021, Markus Elfring wrote: > > The following looks like what one might want to do to find #defines that > > are near each other. > > I have tried another SmPL script variant out. > > > @initialize:python@ > @@ > import sys > > records = {} > > class integrity_error: >pass > >

Re: [Cocci] Replacing #define directives with the help of SmPL

2021-03-28 Thread Julia Lawall
On Sun, 28 Mar 2021, Markus Elfring wrote: > >> Would you like to help any more with attempts to achieve support for > >> a transformation pattern like “#define ⇒ enum” according to the semantic > >> patch language? > >> https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/981 > >>

Re: [Cocci] Replacing #define directives with the help of SmPL

2021-03-28 Thread Julia Lawall
On Sun, 28 Mar 2021, Markus Elfring wrote: > > And what is the problem here? > > Would you like to discuss further software development ideas > according to another SmPL script example like the following? The following looks like what one might want to do to find #defines that are near each

Re: [Cocci] Replacing #define directives with the help of SmPL

2021-03-28 Thread Julia Lawall
On Sun, 28 Mar 2021, Markus Elfring wrote: > >> Another SmPL script example: > >> > >> @display2@ > >> identifier i; > >> expression e; > >> @@ > >> *#define i e > >> > >> > >> elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch > >> show_define_usage2.cocci

Re: [Cocci] Replacing #define directives with the help of SmPL

2021-03-28 Thread Julia Lawall
On Sun, 28 Mar 2021, Markus Elfring wrote: > >> @display@ > >> @@ > >> *#define > > > > Obviously this doesn't work. Just like > > > > @@ > > @@ > > *if > > > > doesnt' work. > > Can it become possible to find such key words in the source code > (by such SmPL search approaches)? No. As has

Re: [Cocci] Replacing #define directives with the help of SmPL

2021-03-28 Thread Julia Lawall
On Sun, 28 Mar 2021, Markus Elfring wrote: > > If you find that something does not work satisfactorily, propose a > > semantic patch and show what doesn't work. > > @display@ > @@ > *#define Obviously this doesn't work. Just like @@ @@ *if doesnt' work. > > I'm not going to try to solve a

Re: [Cocci] Searching only for header files with the Coccinelle software

2021-03-28 Thread Julia Lawall
On Sun, 28 Mar 2021, Markus Elfring wrote: > > Probably the simplest is to put the names of the header files in a file, > > eg find . -name "*h" > header_list, and then give the arguement > > --file-groups header_list to Coccinelle. > > How are the chances to add support for another program

Re: [Cocci] Replacing #define directives with the help of SmPL

2021-03-28 Thread Julia Lawall
On Sun, 28 Mar 2021, Markus Elfring wrote: > >> https://github.com/coccinelle/coccinelle/issues/139 > > > > I looked at the link, but there is no concrete example of something that > > does not work, so I have no idea what the problem is. > > You expressed another bit of better understanding of

Re: [Cocci] Replacing #define directives with the help of SmPL

2021-03-28 Thread Julia Lawall
On Sun, 28 Mar 2021, Markus Elfring wrote: > Hello, > > Will the software development interests ever evolve in ways so that #define > directives > can be replaced with the help of the semantic patch language for special > source code > analysis and transformation approaches? >

Re: [Cocci] Searching only for header files with the Coccinelle software

2021-03-28 Thread Julia Lawall
On Sun, 28 Mar 2021, Markus Elfring wrote: > Hello, > > The Coccinelle software can search for header files in addition to source > files > if the option “--include-headers” was specified. >

Re: [Cocci] [PATCH] coccinelle: misc: restrict patch mode in flexible_array.cocci

2021-03-24 Thread Julia Lawall
On Mon, 8 Mar 2021, Denis Efremov wrote: > Skip patches generation for structs/unions with a single field. > Changing a zero-length array to a flexible array member in a struct > with no named members breaks the compilation. However, reporting > such cases is still valuable, e.g. commit

Re: [Cocci] [PATCH] scripts/coccinelle: Add script to detect sign extension

2021-03-19 Thread Julia Lawall
On Fri, 19 Mar 2021, Evan Benn wrote: > Hello, > > I am attempting to create a coccinelle script that will detect possibly buggy > usage of the bitwise operators where integer promotion may result in bugs, > usually due to sign extension. > > I know this script needs a lot more work, but I am

Re: [Cocci] Removing the last return statement from a void function

2021-03-18 Thread Julia Lawall
On Thu, 18 Mar 2021, Thomas Adam wrote: > Hello all, > > I've another Coccinelle question I'm hoping you can help me with. The > codebase I'm working on is old, and has some interesting styles which > by themselves probably don't cause any problems, but newer C compilers > are now starting to

Re: [Cocci] Incorrect match with when != condition

2021-03-17 Thread Julia Lawall
On Wed, 17 Mar 2021, Denis Efremov wrote: > Hi, > > I'm trying to write the check to detect the absence of commit > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=51b2ee7d006a736a9126e8111d1f24e4fd0afaa6 > in kernel. The pattern can be: > > @err exists@ >

Re: [Cocci] Replacing a struct member with a function call

2021-03-16 Thread Julia Lawall
On Mon, 15 Mar 2021, Mansour Moufid wrote: > On Sun, Mar 14, 2021, 20:43 Thomas Adam wrote: > Hello, > > I can see I was as clear as mud with my explanation -- apologies > for > that, so let me try again. > > In my original example: > > struct monitor { >

Re: [Cocci] Replacing a struct member with a function call

2021-03-15 Thread Julia Lawall
ts on the stack size). That will conclude by telling you the tokens it is most unhappy with. You can often get away with defining a few dummy macros. If none of that works, please send a small function that illustrates the problem and the complete semantic patch. julia > > Kindly

Re: [Cocci] Replacing a struct member with a function call

2021-03-14 Thread Julia Lawall
On Sun, 14 Mar 2021, Wolfram Sang wrote: > > > @@ > > type M; > > This? > > struct monitor* m; > > > @@ > > - m->virtual.width; > > + get_monitor_width(); I guess that m should be somewhere in teh call to get_monitor_width too? julia ___ Cocci

Re: [Cocci] [PATCH v4] coccinelle: misc: add minmax script

2021-03-08 Thread Julia Lawall
> +@pmaxif depends on patch@ > +identifier func; > +expression x, y; > +expression max_val; > +binary operator cmp = {>=, >}; > +@@ > + > +func(...) > +{ > + <... > +-if ((x) cmp (y)) { > +-max_val = (x); > +-} else { > +-max_val = (y); > +-} > ++max_val

Re: [Cocci] linux-kernel janitorial RFP: Mark static arrays as const

2021-03-07 Thread Julia Lawall
On Sun, 7 Mar 2021, Joe Perches wrote: > On Sun, 2021-03-07 at 20:14 +0100, Julia Lawall wrote: > > > > On Wed, 3 Mar 2021, Joe Perches wrote: > > > > > On Wed, 2021-03-03 at 10:41 +0100, Rasmus Villemoes wrote: > > > > On 02/03/2021 18.42, Joe P

Re: [Cocci] linux-kernel janitorial RFP: Mark static arrays as const

2021-03-07 Thread Julia Lawall
On Wed, 3 Mar 2021, Joe Perches wrote: > On Wed, 2021-03-03 at 10:41 +0100, Rasmus Villemoes wrote: > > On 02/03/2021 18.42, Joe Perches wrote: > > > Here is a possible opportunity to reduce data usage in the kernel. > > > > > > $ git grep -P -n

Re: [Cocci] [PATCH v2 RESEND] coccinelle: misc: add minmax script

2021-03-06 Thread Julia Lawall
On Fri, 19 Feb 2021, Denis Efremov wrote: > Check for opencoded min(), max() implementations. > > Signed-off-by: Denis Efremov > --- > > Changes in v2: > - <... ...> instead of ... when any > - org mode reports fixed > - patch rule to drop excessive () > >

Re: [Cocci] linux-kernel janitorial RFP: Mark static arrays as const

2021-03-03 Thread Julia Lawall
On Wed, 3 Mar 2021, Mansour Moufid wrote: > On Tue, Mar 2, 2021 at 4:22 PM Joe Perches wrote: > > > > Here is a possible opportunity to reduce data usage in the kernel. > > > > $ git grep -P -n '^static\s+(?!const|struct)(?:\w+\s+){1,3}\w+\s*\[\s*\]' > > drivers/ | \ > > grep -v __initdata

Re: [Cocci] [PATCH v2] coccinelle: misc: add swap script

2021-03-03 Thread Julia Lawall
On Fri, 19 Feb 2021, Denis Efremov wrote: > Check for opencoded swap() implementation. > > Signed-off-by: Denis Efremov > --- > Changes in v2: > - additional patch rule to drop excessive {} > - fix indentation in patch mode by anchoring ; > > scripts/coccinelle/misc/swap.cocci | 101

Re: [Cocci] linux-kernel janitorial RFP: Mark static arrays as const

2021-03-03 Thread Julia Lawall
On Tue, 2 Mar 2021, Bernd Petrovitsch wrote: > Hi all! > > On 02/03/2021 18:42, Joe Perches wrote: > [...] > > - For instance: (head -10 of the git grep for file statics) > > > > drivers/accessibility/speakup/keyhelp.c:18:static u_short masks[] = { 32, > > 16, 8, 4, 2, 1 }; > >

Re: [Cocci] linux-kernel janitorial RFP: Mark static arrays as const

2021-03-02 Thread Julia Lawall
On Tue, 2 Mar 2021, Joe Perches wrote: > Here is a possible opportunity to reduce data usage in the kernel. Does it actually reduce data usage? julia > > $ git grep -P -n '^static\s+(?!const|struct)(?:\w+\s+){1,3}\w+\s*\[\s*\]' > drivers/ | \ > grep -v __initdata | \ > wc -l > 3250 > >

Re: [Cocci] A few build failures with OCaml 4.12.0

2021-03-02 Thread Julia Lawall
This problem is fixed now in the github version. Thanks again Richard and Markus for the report. julia On Tue, 2 Mar 2021, Richard W.M. Jones wrote: > ocamlfind ocamlopt -c -package result -package seq -bin-annot -no-alias-deps > -I . -alert -deprecated stdcompat__arg_s.mli -o

Re: [Cocci] A few build failures with OCaml 4.12.0

2021-03-02 Thread Julia Lawall
On Tue, 2 Mar 2021, Richard W.M. Jones wrote: > ocamlfind ocamlopt -c -package result -package seq -bin-annot -no-alias-deps > -I . -alert -deprecated stdcompat__arg_s.mli -o stdcompat__arg_s.cmi > File "stdcompat__arg_s.mli", lines 3-17, characters 0-38: > 3 | type spec = Arg.spec = > 4 |

Re: [Cocci] release of version 1.1.0

2021-02-27 Thread Julia Lawall
On Sat, 27 Feb 2021, Denis Efremov wrote: > > > On 2/27/21 12:14 PM, Julia Lawall wrote: > > > > > > On Sat, 27 Feb 2021, Denis Efremov wrote: > > > >> Hi, > >> > >> Great news! > >> > >> Could you please crea

Re: [Cocci] release of version 1.1.0

2021-02-27 Thread Julia Lawall
rsion 1.0.9. We moved on to 1.1 due to the #spatch feature. julia > Thanks, > Denis > > On 2/27/21 11:11 AM, Julia Lawall wrote: > > A new version 1.1.0 has been released. The most interesting change is the > > ability to put spatch command line options in a .cocci file, for exa

[Cocci] release of version 1.1.0

2021-02-27 Thread Julia Lawall
A new version 1.1.0 has been released. The most interesting change is the ability to put spatch command line options in a .cocci file, for example: #spatch --very-quiet -j 8 --recursive-includes --include-headers-for-types Other specific improvements are an improved handling of attributes and a

Re: [Cocci] [PATCH] coccinelle: misc: add swap script

2021-02-18 Thread Julia Lawall
On Thu, 18 Feb 2021, Markus Elfring wrote: > > A disjunction basically says "at this node in the cfg, can I match the > > first patter, or can I match the second pattern, etc." Unfortunately in > > this case the two branches start matching at different nodes, so the short > > circuit aspect

Re: [Cocci] [PATCH] coccinelle: misc: add swap script

2021-02-18 Thread Julia Lawall
On Thu, 18 Feb 2021, Denis Efremov wrote: > > > On 2/18/21 1:17 PM, Julia Lawall wrote: > > > > > > On Thu, 18 Feb 2021, Denis Efremov wrote: > > > >> > >> > >> On 2/18/21 12:31 AM, Julia Lawall wrote: > >>>> +@depend

Re: [Cocci] Problem with partial patch generation

2021-02-15 Thread Julia Lawall
On Mon, 15 Feb 2021, Denis Efremov wrote: > > > On 2/15/21 2:47 PM, Julia Lawall wrote: > > > > > > On Mon, 15 Feb 2021, Denis Efremov wrote: > > > >> Hi, > >> > >> I wrote a simple rule (swap.cocci): > >> > >> v

Re: [Cocci] Problem with partial patch generation

2021-02-15 Thread Julia Lawall
On Mon, 15 Feb 2021, Denis Efremov wrote: > Hi, > > I wrote a simple rule (swap.cocci): > > virtual patch > > @depends on patch@ > identifier tmp; > expression a, b; > type T; > @@ > > ( > - T tmp; > | > - T tmp = 0; > | > - T *tmp = NULL; > ) > ... when != tmp > - tmp = a; > - a = b; > - b =

Re: [Cocci] Problem with partial patch generation

2021-02-15 Thread Julia Lawall
On Mon, 15 Feb 2021, Denis Efremov wrote: > Hi, > > I wrote a simple rule (swap.cocci): > > virtual patch > > @depends on patch@ > identifier tmp; > expression a, b; > type T; > @@ > > ( > - T tmp; > | > - T tmp = 0; > | > - T *tmp = NULL; > ) > ... when != tmp > - tmp = a; > - a = b; > - b =

Re: [Cocci] Missing package for Ubuntu 20.04 LTS?

2021-02-13 Thread Julia Lawall
On Sat, 13 Feb 2021, Taylor Blau wrote: > Hi Julia, > > On Fri, Feb 12, 2021 at 03:06:16PM +0100, Julia Lawall wrote: > > > Is there a planned release of coccinelle that will appear in the focal > > > suite? > > > > Can you use the PPA? > > >

Re: [Cocci] Backward compatibility issue

2021-02-12 Thread Julia Lawall
On Fri, 12 Feb 2021, Denis Efremov wrote: > > > On 2/12/21 5:04 PM, Julia Lawall wrote: > > > > > > On Thu, 11 Feb 2021, Denis Efremov wrote: > > > >> Hi, one of my patterns started to fail tests on latest coccinelle. > >> I've bisected th

Re: [Cocci] Missing package for Ubuntu 20.04 LTS?

2021-02-12 Thread Julia Lawall
On Tue, 9 Feb 2021, Taylor Blau wrote: > Hi, > > The Git project recently noticed that our static analysis builds were > failing after upgrading to Ubuntu 20.04 due to being unable to find the > coccinelle package in the focal suite. > >

Re: [Cocci] Backward compatibility issue

2021-02-12 Thread Julia Lawall
On Thu, 11 Feb 2021, Denis Efremov wrote: > Hi, one of my patterns started to fail tests on latest coccinelle. > I've bisected the commit that introduces "error". It's: > commit db60e916633d2cb3ae31140364783fdf85ed10f4 > "make information about SmPL iterator and declarer names available to the

Re: [Cocci] Backward compatibility issue

2021-02-11 Thread Julia Lawall
On Thu, 11 Feb 2021, Denis Efremov wrote: > Hi, one of my patterns started to fail tests on latest coccinelle. > I've bisected the commit that introduces "error". It's: > commit db60e916633d2cb3ae31140364783fdf85ed10f4 > "make information about SmPL iterator and declarer names available to the

Re: [Cocci] qualified function rule

2021-01-27 Thread Julia Lawall
On Wed, 27 Jan 2021, James K. Lowden wrote: > I don't understand how, if it's possible, to qualify a function in a > rule. I want the class of all functions having a parameter of a > particular type. > > The code I'm working with has hundreds of unnecessary casts. Many > functions take a

[Cocci] online talk

2021-01-22 Thread Julia Lawall
Hello, I will give a tutorial talk about Coccinelle on February 2, at 7:30AM PST. It is possible to register at the following link: https://events.linuxfoundation.org/mentorship-session-coccinelle/ julia ___ Cocci mailing list Cocci@systeme.lip6.fr

Re: [Cocci] Performance issue with quite simple patch?

2021-01-13 Thread Julia Lawall
On Wed, 13 Jan 2021, Maxime Ripard wrote: > Hi! > > I've been trying to get a patch to rename any variable called "state" in > a given set of callbacks. > > This is the patch that I've come up with: > > @ plane_atomic_func @ > identifier helpers; > identifier func; > @@ > > ( > static const

Re: [Cocci] How to match switch cases and their absence with coccinelle?

2021-01-12 Thread Julia Lawall
On Tue, 12 Jan 2021, Denis Efremov wrote: > > > On 1/12/21 7:13 PM, Julia Lawall wrote: > > > > > > On Tue, 12 Jan 2021, Denis Efremov wrote: > > > >> Hi, > >> > >> Let's suppose I have this pattern: > >>

Re: [Cocci] How to match switch cases and their absence with coccinelle?

2021-01-12 Thread Julia Lawall
On Tue, 12 Jan 2021, Denis Efremov wrote: > Hi, > > Let's suppose I have this pattern: > @fix exists@ > position p; > @@ > > binder_release_work(...) > { > ... > switch (...) { > * case BINDER_WORK_NODE: ... break;@p > } > ... Add when any to the outer ...s

Re: [Cocci] How to match function-like macro calls, e.g. RTA_ALIGN(rta->rta_len)?

2021-01-11 Thread Julia Lawall
On Mon, 11 Jan 2021, Denis Efremov wrote: > > > On 1/11/21 11:40 PM, Julia Lawall wrote: > > > > > > On Mon, 11 Jan 2021, Denis Efremov wrote: > > > >> > >> > >> On 1/11/21 11:23 PM, Julia Lawall wrote: > >>&g

Re: [Cocci] How to match function-like macro calls, e.g. RTA_ALIGN(rta->rta_len)?

2021-01-11 Thread Julia Lawall
On Mon, 11 Jan 2021, Denis Efremov wrote: > > > On 1/11/21 11:23 PM, Julia Lawall wrote: > > > > > > On Mon, 11 Jan 2021, Denis Efremov wrote: > > > >> Hi, > >> > >> Let's suppose I want to match otx_cpt_aead_cbc_aes_sha_setke

Re: [Cocci] How to match function-like macro calls, e.g. RTA_ALIGN(rta->rta_len)?

2021-01-11 Thread Julia Lawall
On Mon, 11 Jan 2021, Denis Efremov wrote: > Hi, > > Let's suppose I want to match otx_cpt_aead_cbc_aes_sha_setkey() function from > drivers/crypto/marvell/octeontx/otx_cptvf_algs.c file (linux kernel). > > My pattern: > @exists@ > identifier rta, param, key, keylen; > position p; > @@ > >

Re: [Cocci] Matching attributes

2021-01-08 Thread Julia Lawall
> But this fails: > > @@ > type T; > identifier var; > attribute name autofree; > @@ > > T var autofree; > ... > ++ free(var); > return ...; > > with > > minus: parse error: >File "autofree.cocci", line 7, column 17, charpos = 73 >around = ';', >whole content =T

Re: [Cocci] Python 3.10 again: _Py_fopen deprecated

2021-01-08 Thread Julia Lawall
On Tue, 5 Jan 2021, Richard W.M. Jones wrote: > Firstly a gentle reminder that there's a patch waiting to be applied: > https://systeme.lip6.fr/pipermail/cocci/2020-November/thread.html#8398 > > Different from that patch, but still related to Python 3.10, we've got > another bug report here: >

Re: [Cocci] cocci: missed strlcpy->strscpy conversion?

2020-12-31 Thread Julia Lawall
On Thu, 31 Dec 2020, Joe Perches wrote: > On Thu, 2020-12-31 at 21:27 +0100, Julia Lawall wrote: > > On Thu, 31 Dec 2020, Joe Perches wrote: > > > On Thu, 2020-12-31 at 11:04 -0800, Joe Perches wrote: > > > > strlcpy is deprecated. see: Docume

Re: [Cocci] cocci: missed strlcpy->strscpy conversion?

2020-12-31 Thread Julia Lawall
On Thu, 31 Dec 2020, Joe Perches wrote: > On Thu, 2020-12-31 at 21:27 +0100, Julia Lawall wrote: > > On Thu, 31 Dec 2020, Joe Perches wrote: > > > On Thu, 2020-12-31 at 11:04 -0800, Joe Perches wrote: > > > > strlcpy is deprecated. see: Docume

Re: [Cocci] cocci: missed strlcpy->strscpy conversion?

2020-12-31 Thread Julia Lawall
On Thu, 31 Dec 2020, Joe Perches wrote: > On Thu, 2020-12-31 at 11:04 -0800, Joe Perches wrote: > > strlcpy is deprecated. see: Documentation/process/deprecated.rst > > > > Change the calls that do not use the strlcpy return value to the > > preferred strscpy. > > > > Done with cocci script:

Re: [Cocci] [PATCH v3] scripts: coccicheck: Correct usage of make coccicheck

2020-12-24 Thread Julia Lawall
On Wed, 25 Nov 2020, Sumera Priyadarsini wrote: > The command "make coccicheck C=1 CHECK=scripts/coccicheck" results in the > error: > ./scripts/coccicheck: line 65: -1: shift count out of range > > This happens because every time the C variable is specified, > the shell arguments need

  1   2   3   4   5   6   7   8   9   10   >