Re: [Cocci] [PATCH v2 2/4] coccinelle: api: extend memdup_user rule with vmemdup_user()

2020-06-08 Thread Markus Elfring
>>> +* to = \(kvmalloc@p\|kvzalloc@p\)(size,\(GFP_KERNEL\|GFP_USER\)); >>> + if (to==NULL || ...) S1 >>> + if (copy_from_user(to, from, size) != 0) >>> + S2 >> >> How does the SmPL asterisk functionality fit to the operation >> modes “org” and “report”? > > Make coccicheck uses

Re: [Cocci] [PATCH v2 4/4] coccinelle: api: add selfcheck for memdup_user rule

2020-06-08 Thread Markus Elfring
> Check that the rule matches vmemdup_user implementation. > memdup_user is out of scope because we are not matching > kmalloc_track_caller() function. I find this change description improvable. Will it become helpful (for example) to mention that you would like to add another operation mode? >

Re: [Cocci] [PATCH v2 3/4] coccinelle: api: filter out memdup_user definitions

2020-06-08 Thread Markus Elfring
> Don't match original implementations. I find such a change description insufficient. Regards, Markus ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci

Re: [Cocci] [PATCH v2 2/4] coccinelle: api: extend memdup_user rule with vmemdup_user()

2020-06-08 Thread Markus Elfring
… +++ b/scripts/coccinelle/api/memdup_user.cocci @@ -39,6 +39,28 @@ … … > +@depends on patch@ > +expression from,to,size; > +identifier l1,l2; > +@@ > + > +- to = \(kvmalloc\|kvzalloc\)(size,\(GFP_KERNEL\|GFP_USER\)); > ++ to = vmemdup_user(from,size); I suggest to combine the desired

Re: [Cocci] [PATCH v2 1/4] coccinelle: api: extend memdup_user transformation with GFP_USER

2020-06-08 Thread Markus Elfring
> Match GFP_USER and optional __GFP_NOWARN allocations with > memdup_user.cocci rule. You suggest another interesting software extension. … > +++ b/scripts/coccinelle/api/memdup_user.cocci > @@ -20,7 +20,9 @@ expression from,to,size; > identifier l1,l2; > @@ > > -- to =

Re: [Cocci] [PATCH 0/4] parsing_c: parser: Add end_attributes_opt rule

2020-06-08 Thread Markus Elfring
> Patches for improving the C parsing of attributes[1] introduced a lot > redundant code in the C parser. This patch series resolves this by adding > a rule for optional end attributes and merging the redundant code > together. > > [1] > [PATCH v2 00/25] cocci: Improve C parsing of attributes >

Re: [Cocci] Python interface

2020-06-08 Thread Markus Elfring
> OK, basically I worry about converting a list of 35 000 file names to python. Can such development concerns be adjusted? > But maybe it's not a big deal. Will additional search filters, dependencies and better algorithms improve the software situation finally? Regards, Markus

Re: [Cocci] Python interface

2020-06-08 Thread Markus Elfring
> > … But I wonder if the difference > > between "the file is not in the initial list" and "the file is in the > > initial list but it is ignored" is important for you? > > "the file is in the initial list but it is ignored" is ok to me. I don't know > how to get it. Which information are you

Re: [Cocci] Python interface

2020-06-08 Thread Markus Elfring
> > … But I wonder if the difference > > between "the file is not in the initial list" and "the file is in the > > initial list but it is ignored" is important for you? > > "the file is in the initial list but it is ignored" is ok to me. I don't know > how to get it. Which information are you

Re: [Cocci] Python interface

2020-06-08 Thread Markus Elfring
>> Should the software be able to determine just the amount of script code >> between the curly brackets? > > What if there is a string or comment inside the script code, ant it > contains only a }? I suggest to consider corresponding escaping (or quoting) of questionable text. > Anyway the

Re: [Cocci] Checking source file selections

2020-06-08 Thread Markus Elfring
> I need a list of all files spatch tries to process. I am curious about this expectation. > A list of files in which spatch finds some matches is not enough. > Otherwise the approach will incorrectly work when cocci script runs on > a subset of kernel files, e.g., > make coccicheck

Re: [Cocci] Python interface

2020-06-08 Thread Markus Elfring
> > > @r depends on !patch@ > > // It doesn't work. Is it normal? > > //position p: script:python() { matches.extend(p); relevant(p) }; > > "Doesn't work" means you get a parse error? The parser of the code inside > the {} is pretty fragile. I find such information also interesting. > Perhaps

Re: [Cocci] Suppressing a couple of matches

2020-06-08 Thread Markus Elfring
> Let us suppose that I want to suppress a couple of matches because they are > false-positives. Do you try to avoid the generation of false positives for your source code analysis? > However, I still want to check they exists in finalize block and print a > warning otherwise. > This is some

Re: [Cocci] Coccinelle: Extending capabilities for source file pre-selection

2020-06-07 Thread Markus Elfring
>> Coccinelle is not able to optimize its search process > > The software contains some limitations which might be changeable. > > >> according to the information in constraints. > > Will related solution ideas become more interesting? I propose to move parts of the mentioned concerns out of the

Re: [Cocci] Coccinelle: Improving software components around usage of SmPL disjunctions

2020-06-07 Thread Markus Elfring
>> But hiding information that could be apparent to the SmPL compiler >> and could be used to improve the performance of the matching >> process is not one of them. > > Will any software extensions become possible also in this area? You pointed out that SmPL disjunctions can trigger specific

Re: [Cocci] coccinelle: api: add kvfree script

2020-06-06 Thread Markus Elfring
>> * A limited search approach was expressed. Will additional source code >> variations >> become relevant? >> + switch statement >> + if branches with single statements >> + conditional operator > > The point is that there is a kmalloc in one branch and a vmalloc in > another branch, so

Re: [Cocci] [PATCH] coccinelle: api: add kvfree script

2020-06-06 Thread Markus Elfring
> +@choice@ > +expression E, E1; > +position kok, vok; > +@@ > + > +( > + if (...) { > +... > +E = \(kmalloc@kok\|…\)(...) Further implementation details from this SmPL script caught my software development attention. * Is there a need to add the specification “when any” to the SmPL

Re: [Cocci] coccinelle: api: add kvfree script

2020-06-06 Thread Markus Elfring
> So there are a lot of reasons why constraints are useful. Thanks for such a view. Thus I dare to point the possibility out to consider their application for mentioned function name lists (besides using SmPL disjunctions). Can coding style concerns be resolved in a more constructive way then?

Re: [Cocci] coccinelle: api: add kvfree script

2020-06-06 Thread Markus Elfring
>>> +E = >>> \(kmalloc@kok\|kzalloc@kok\|krealloc@kok\|kcalloc@kok\|kmalloc_node@kok\|kzalloc_node@kok\|kmalloc_array@kok\|kmalloc_array_node@kok\|kcalloc_node@kok\)(...) >> >> I would prefer an other coding style here. >> >> * Items for such SmPL disjunctions can be specified also on

Re: [Cocci] coccinelle: api: add kvfree script

2020-06-06 Thread Markus Elfring
>>> +E = >>> \(kmalloc@kok\|kzalloc@kok\|krealloc@kok\|kcalloc@kok\|kmalloc_node@kok\|kzalloc_node@kok\|kmalloc_array@kok\|kmalloc_array_node@kok\|kcalloc_node@kok\)(...) >> >> I would prefer an other coding style here. >> >> * Items for such SmPL disjunctions can be specified also on

Re: [Cocci] [PATCH] coccinelle: api: add kvfree script

2020-06-06 Thread Markus Elfring
> Check that alloc and free types of functions match each other. Further software development challenges are interesting also for such an use case. > +/// Check that kvmalloc'ed memory is freed by kfree functions, > +/// vmalloc'ed by vfree functions and kvmalloc'ed by kvfree > +/// functions.

Re: [Cocci] coccinelle: api: add kzfree script

2020-06-06 Thread Markus Elfring
> Is avoiding transforming the case where E is not verified to be a pointer a > concern? I imagine that answers to this question have got consequences also on the confidence level for such SmPL scripts. The desire and requirement to specify data type restrictions (for expressions) can influence

Re: [Cocci] [PATCH v2] coccinelle: api: add kzfree script

2020-06-05 Thread Markus Elfring
> Check for memset()/memset_explicit() with 0 followed by > kfree()/vfree()/kvfree(). Another software evolution will become interesting here. > +/// memset_explicit with 0 followed by kfree How do you think about to extend this comment? Would you like to take the following SmPL code

Re: [Cocci] [PATCH v2] coccinelle: api: add kzfree script

2020-06-04 Thread Markus Elfring
> On the other hand, do you really require E to be a pointer? > If you do that, it will have to find the type of E. I suggest to reconsider this information. > If E refers to a structure field, then the type might not be available > in the current function, and you may need command line

Re: [Cocci] [PATCH] Coccinelle: Add dummy report mode to add_namespace.cocci

2020-06-04 Thread Markus Elfring
> … when run trough I hope that a typo will be avoided for the final change description. Regards, Markus ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci

Re: [Cocci] coccinelle: api: add kzfree script

2020-06-04 Thread Markus Elfring
>>> +virtual context >>> +virtual org >>> +virtual report >>> +virtual patch >> >> +virtual context, org, report, patch > > This is pointless. I find the proposed SmPL code variant more succinct. >> How does the SmPL asterisk functionality fit to the operation >> modes “org” and “report”? > >

Re: [Cocci] [PATCH] coccinelle: api: add kzfree script

2020-06-04 Thread Markus Elfring
> Check for memset() with 0 followed by kfree(). I suggest to simplify the SmPL code a bit like the following. > +virtual context > +virtual org > +virtual report > +virtual patch +virtual context, org, report, patch … > +@@ > + > +( > +* memset(E, 0, ...); > +| > +* memset(E, '\0', ...); >

Re: [Cocci] Software documentation for “subE”?

2020-06-04 Thread Markus Elfring
> subE is a expressionof whatever expression was previously matched to E in > the rule ifm. <= can only be used when the metavariable on the right side > is inherited from another rule. Under which circumstances will a clearer explanation appear also for software documentation formats besides a

Re: [Cocci] How to handle parts of expressions?

2020-06-04 Thread Markus Elfring
> I'm trying to write a rule to match consecutive function calls. For example: > @r@ > expression E, E1; > @@ > > call_func(E); > ... when != E = E1 > * call_func(E); > > It works well, but not in case "E == p->f" and p is updated in between calls. > So, I'm to understand how can I avoid these

Re: [Cocci] Excluding function names in SmPL rules

2020-06-03 Thread Markus Elfring
>> Do you find the following source code search approach helpful for >> your software development needs? > > No. It is a pity that this SmPL example does still not work in the way which you expect so far. > It's the first approach I tried and it didn't match anything anymore; > I couldn't

Re: [Cocci] Excluding function names in SmPL rules

2020-06-03 Thread Markus Elfring
> I couldn't find a way to do that from the first rule, so I whitelisted > send_drop_notify() with a second rule (rule2 below). That seems rather > cumbersome and I'm wondering if there's maybe a simpler approach? Do you find the following source code search approach helpful for your software

Re: [Cocci] [PATCH 2/2] Coccinelle: extend memdup_user rule with vmemdup_user()

2020-06-01 Thread Markus Elfring
> +@rv depends on !patch@ > +expression from,to,size; > +position p; > +statement S1,S2; > +@@ > + > +* to = \(kvmalloc@p\|kvzalloc@p\)(size,\(GFP_KERNEL\|GFP_USER\)); > + if (to==NULL || ...) S1 > + if (copy_from_user(to, from, size) != 0) > + S2 How does the SmPL asterisk functionality

Re: [Cocci] [2/2] Coccinelle: memdup_user: Extending data processing for special tokens

2020-05-31 Thread Markus Elfring
> Unfortunately, the Coccinelle software does not like the following > SmPL code variant so far. > > to = > ( > - \( kmalloc \| kzalloc \) > + memdup_user > | > - \( kvmalloc \| kvzalloc \) > + vmemdup_user > ) > ( > - size, \( GFP_KERNEL \|

Re: [Cocci] [PATCH 2/2] Coccinelle: extend memdup_user rule with vmemdup_user()

2020-05-31 Thread Markus Elfring
> Add vmemdup_user() transformations to the memdup_user.cocci rule. > Commit 50fd2f298bef ("new primitive: vmemdup_user()") introduced > vmemdup_user(). The function uses kvmalloc with GPF_USER flag. Such a software evolution is also interesting. > +@depends on patch@ > +- to =

Re: [Cocci] [PATCH 1/2] Coccinelle: extend memdup_user transformation with GFP_USER

2020-05-31 Thread Markus Elfring
> Match GFP_USER allocations with memdup_user.cocci rule. Can this software extension help also for the clarification of the topic “Safer source code analysis by "memdup_user.cocci"”? https://github.com/coccinelle/coccinelle/issues/78 Regards, Markus

Re: [Cocci] [PATCH v3 00/32] cocci: Add cast attributes to C and SmPL ASTs

2020-05-30 Thread Markus Elfring
… [1]https://www.mail-archive.com/cocci@systeme.lip6.fr/msg07133.html … Would a link variant like the following be safer for the desired information? [1]: [RFC PATCH 00/25] cocci: Improve C parsing of attributes https://systeme.lip6.fr/pipermail/cocci/2020-April/007205.html

Re: [Cocci] [PATCH v3 1/2] drivers: provide devm_platform_request_irq()

2020-05-27 Thread Markus Elfring
> It will call devm_request_irq() after platform_get_irq() function > in many drivers, sometimes, it is not right for the error handling > of these two functions in some drivers. so provide this function > to simplify the driver. I recommend to improve also this change description. How do you

Re: [Cocci] Using SmPL scripts to mangle function arguments

2020-05-27 Thread Markus Elfring
> I'm having trouble expressing my smPL to understand the ellipses correctly. I am curious how the application of scripts for the semantic patch language will grow according to your software development needs.

Re: [Cocci] Using SmPL scripts to mangle function arguments

2020-05-26 Thread Markus Elfring
> > @@ > > expression L, F; > > @@ > > > > - func_old(L, F, ...); > > + func_old(__func_, ...); > > You can't add ... Coccinelle has no idea what it refers to. The software knows something about the involved source code. This knowledge can be applied according to the functionality of the SmPL

Re: [Cocci] Using SmPL scripts to mangle function arguments

2020-05-26 Thread Markus Elfring
> func_old(__func__, "%s: hello: %d, %d", myvar, x, y); > > I'm having trouble expressing my smPL to understand the ellipses correctly. This can be usual. > Here's what I have so far: > > @@ > expression L, F; > @@ > > - func_old(L, F, ...); > + func_old(__func_, ...); > > ... but here, things

Re: [Cocci] Converting variable initialisations to later assignments

2020-05-25 Thread Markus Elfring
>>> I already asked above what you expected the ++ code to be attached to. >>> All added code has to be attached to something. >> >> Can the connection to the desired source code position be achieved also >> by the application of the SmPL ellipsis together with code exclusions? > > No. Do you

Re: [Cocci] Converting variable initialisations to later assignments

2020-05-24 Thread Markus Elfring
>> ; >> ... when any >> when != S >> ++ V2 = E; >> … >>> I already asked above what you expected the ++ code to be attached to. >>> All added code has to be attached to something. >> >> Can the connection to the desired source code position be achieved also >> by the

Re: [Cocci] Converting variable initialisations to later assignments

2020-05-24 Thread Markus Elfring
; ... when any when != S ++ V2 = E; … > I already asked above what you expected the ++ code to be attached to. > All added code has to be attached to something. Can the connection to the desired source code position be achieved also by the application of the SmPL

Re: [Cocci] Converting variable initialisations to later assignments

2020-05-24 Thread Markus Elfring
@movement@ expression E; identifier V1, V2, Vx; statement S; type T1, T2; @@ T1 V1; ... when any T2 V2 - = \( <+... Vx ...+> \& E \) >>> >>> What is Vx for? He wants an expression that involves a. >> >> I chose a slightly more unique

Re: [Cocci] Converting variable initialisations to later assignments

2020-05-24 Thread Markus Elfring
>> @movement@ >> expression E; >> identifier V1, V2, Vx; >> statement S; >> type T1, T2; >> @@ >> T1 V1; >> ... when any >> T2 V2 >> - = \( <+... Vx ...+> \& E \) > > What is Vx for? He wants an expression that involves a. I chose a slightly more unique metavariable identifier for the

Re: [Cocci] Converting variable initialisations to later assignments

2020-05-24 Thread Markus Elfring
> > I am trying to move local variable initialization of some variable to > > first statement. … I find such a source code transformation task also interesting. But it points some software development challenges out also for the safe application of the semantic patch language for this use case.

Re: [Cocci] How to match function calls in macros?

2020-05-19 Thread Markus Elfring
>>> If it is working on a function definition, it works only on that function >>> definition. >> >> Does the position of the define directive influence this view? > > I believe that the #defines inside of other top-level definitions are ignored. I find such a feedback surprising. It seems that

Re: [Cocci] How to match function calls in macros?

2020-05-19 Thread Markus Elfring
>> With which SmPL constructs should be ensured that a search pattern >> like “<+... f(...) ...+>” refers only to content from the same logical >> source line? >> https://en.cppreference.com/w/c/language/translation_phases#Phase_2 > > Please stop asking the same question over and over. I hope

Re: [Cocci] How to match function calls in macros?

2020-05-19 Thread Markus Elfring
>> Can the semantic patch language help to insist for a search that a bit >> of source code belongs to the implementation of a function-like macro? > > That's what the search that was written does. The pattern that comes > after #define has to be in the definition of the macro. I suggest to

Re: [Cocci] How to match function calls in macros?

2020-05-18 Thread Markus Elfring
> If the developer forgets the \ there would likely be a parsing problem. Another information can be helpful then. elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --parse-c INIT_WORK-Test-20200518.c … SUSPICIOUS: a \ character appears outside of a #define at INIT_WORK-Test-20200518.c:4

Re: [Cocci] How to match function calls in macros?

2020-05-18 Thread Markus Elfring
>> Can the semantic patch language help to insist for a search that a bit >> of source code belongs to the implementation of a function-like macro? > > That's what the search that was written does. I interpret the example in another way. *#define mac(...) <+... f(...) ...+> > The pattern that

Re: [Cocci] How to match function calls in macros?

2020-05-18 Thread Markus Elfring
>>> If the developer forgets the \ there would likely be a parsing problem. >> >> I find it helpful to clarify parsing challenges around such an use case. >> It might occasionally be relevant if a line continuation indication >> was accidentally forgotten or was intentionally omitted. >> >> *

Re: [Cocci] How to match function calls in macros?

2020-05-18 Thread Markus Elfring
>> How would (or should) the Coccinelle software handle the mentioned search >> pattern >> if such a line continuation indication was omitted between a macro >> declaration >> and subsequent source code? > > The macro ends at the first line that doesn't end with a \ This is fine. > If the

Re: [Cocci] How to match function calls in macros?

2020-05-18 Thread Markus Elfring
>>> @@ >>> identifier mac,f; >>> @@ >>> >>> *#define mac(...) <+... f(...) ...+> >> >> Does such an analysis approach restrict the source code search really on >> complete definitions for function-like macros? > > Coccinelle knows where the macro ends. This is good to know. > A macro has to be

Re: [Cocci] How to match function calls in macros?

2020-05-18 Thread Markus Elfring
> @@ > identifier mac,f; > @@ > > *#define mac(...) <+... f(...) ...+> Does such an analysis approach restrict the source code search really on complete definitions for function-like macros? Will it become interesting for clarify corresponding special cases? * How are empty macros treated by

Re: [Cocci] Using SmPL scripts to mangle function arguments

2020-05-17 Thread Markus Elfring
> Hence, func_new() reduces the number of arguments to just one > -- a format string, and variadic arguments. * Does this wording contain a contradiction? * Would you like to fiddle with any more variadic functions? > My question is how would I go about trying to get coccinelle to help me >

[Cocci] Support for multi-line “when code” by SmPL?

2020-05-17 Thread Markus Elfring
Hello, The manual for the semantic patch language provides the following information. https://github.com/coccinelle/coccinelle/blob/7cf2c23e64066d5249a64a316cc5347831f7a63f/docs/manual/cocci_syntax.tex#L1122 … when ::= when != when_code … when_code ::= OPTDOTSEQ(decl_stmt+, when)

Re: [Cocci] How to match function calls in macros?

2020-05-16 Thread Markus Elfring
> Normally, Coccinelle will match code inside of macro definitions, > but only if it is able to parse the macro definition, This is good to know. > and the ability to parse macro definitions is somewhat limited. How are the chances to reduce any software limitations in this area? Regards,

Re: [Cocci] Checking an application of the SmPL construct “<+... … ...+>”

2020-05-07 Thread Markus Elfring
>> @display@ >> @@ >> (dev_err >> |dev_info >> ) ( >> *<+... get_device(...) ...+> >> ) >> >> >> Is such a test result worth for further software development considerations? > > No. > > <+... ...+> as an expression matches a single expression. How does this information fit

[Cocci] Checking an application of the SmPL construct “<+... … ...+>”

2020-05-07 Thread Markus Elfring
Hello, I have tried further script variants out for the semantic patch language (according to the software combination “Coccinelle 1.0.8-00087-g7cf2c23e”). Source code example: // SPDX-License-Identifier: GPL-2.0-only // deleted part static int sca3000_read_data(struct sca3000_state *st,

Re: [Cocci] Exit with non-zero status

2020-05-06 Thread Markus Elfring
> We're only planning to add Coccinelle rules in the future. I am curious how software extensions will evolve further in this area. > If we need more complex post-processing, I imagine that the selection of nicer data structures can occasionally become more interesting. > we'll likely

Re: [Cocci] Exit with non-zero status

2020-05-05 Thread Markus Elfring
> For the record, I enabled Coccinelle in our CI (GitHub Actions) > yesterday and worked around that issue with the following script: > > make -C bpf/ coccicheck | tee /tmp/stdout > exit $(grep -c "[prefix of warning messages]" /tmp/stdout) I propose to improve the data processing approach

Re: [Cocci] Checking the application of the SmPL isomorphism “drop_else”

2020-05-03 Thread Markus Elfring
> I hoped for another clarification also for the message “warning: iso drop_else > does not match the code below on line 55” (and the corresponding debug > display). I imagine that there is another bit of fine-tuning possible. >> There is an isomorphism that drops else's in ifs, but that only

Re: [Cocci] Searching for global items in the source code

2020-05-02 Thread Markus Elfring
>>> In this case, the problem entirely on your side. You should separate the >>> two top-level declarations into two separate rules, just like any other >>> two top-level declarations you would like to match. >> >> My SmPL script example affects the understanding of the software behaviour >> also

Re: [Cocci] Searching for global items in the source code

2020-05-01 Thread Markus Elfring
>> @display@ >> identifier action; >> type return_type; >> @@ >> *return_type action(...) >> { >> ... >> } >> EXPORT_SYMBOL(action); … > In this case, the problem entirely on your side. You should separate the > two top-level declarations into two separate rules, just like any other > two

Re: [Cocci] Searching for exported Linux functions

2020-05-01 Thread Markus Elfring
>> @display@ >> identifier action; >> type return_type; >> @@ >> *return_type action(...) >> { >> ... >> } >> EXPORT_SYMBOL(action); >> >> >> But I get the following error message so far. >> >> elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch --parse-cocci >> show_exported_functions1.cocci

[Cocci] Searching for exported Linux functions

2020-05-01 Thread Markus Elfring
Hello, I would like to determine specific information also by the means of another script for the semantic patch language. @display@ identifier action; type return_type; @@ *return_type action(...) { ... } EXPORT_SYMBOL(action); But I get the following error message so far.

Re: [Cocci] Checking SmPL data processing for enumerations

2020-04-30 Thread Markus Elfring
>> @display@ >> int i; >> @@ >> return >> * -i >> ; … >> Why are source code places presented which do not contain a key word >> I was looking for this test approach? > > I don't know. With --debug you can see that there are only two matches. > So maybe it is a pretty printing problem.

[Cocci] Checking search results for two enumerations

2020-04-30 Thread Markus Elfring
Hello, I have tried another tiny script out for the semantic patch language (according to the software combination “Coccinelle 1.0.8-00029-ga549b9f0”). @display@ int i; @@ return * -i ; Are the following search results worth for further software development considerations?

Re: [Cocci] Exit with non-zero status

2020-04-29 Thread Markus Elfring
>> I suggest to handle the desired search result counter >> by an other data processing interface. >> How would you like to treat program execution failures otherwise? > > I'm trying to run SmPL programs as part of a CI pipeline, so execution > failure and (buggy) code pattern not found really

Re: [Cocci] Exit with non-zero status

2020-04-29 Thread Markus Elfring
> I am trying to exit spatch with a non-zero exit status when required > changes have been found. I got used to the interpretation that a zero exit status should indicate a successful execution of the program. > @finalize:python@ > @@ > exit(cnt) > > where cnt is incremented by another

Re: [Cocci] [PATCH] dpaa_eth: Fix comparing pointer to 0

2020-04-27 Thread Markus Elfring
> Fixes coccicheck warning: > ./drivers/net/ethernet/freescale/dpaa/dpaa_eth.c:2110:30-31: > WARNING comparing pointer to 0 Such information is actually provided by a known script for the semantic patch language.

Re: [Cocci] [RFC 00/25] cocci: Improve C parsing of attributes

2020-04-25 Thread Markus Elfring
>>> These parsing errors were discovered by running a build of >>> Coccinelle's >> >> Would you like to omit the word “These”? … > Could you please keep your feedback relevant to the actual patch itself > (or the commit messages)? I contributed another review comment also at this place. >

[Cocci] Evolution around the information “try to delete an expanded token”?

2020-04-25 Thread Markus Elfring
Hello, I have tried another small script out for the semantic patch language (according to the software combination “Coccinelle 1.0.8-00029-ga549b9f0”). @display@ expression e, x != { PTR_ERR }, y; statement is, es; type t; @@ *e = (t) x(...) ... when != if (<+... e ...+>) is else es when

Re: [Cocci] [RFC PATCH 23/25] parsing_c: type_c: Add parameter attributes to record

2020-04-24 Thread Markus Elfring
> Paramter attributes are added to the C AST. Please avoid a typo in the first word for this change description. Regards, Markus ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci

Re: [Cocci] [RFC PATCH 17/25] engine: cocci_vs_c: Add allminus argument to attribute_list

2020-04-24 Thread Markus Elfring
> This also makes sure that the test case unstruct does not break when > attributes are identified correctly by the C parser. Would the wording “are correctly identified” be more appropriate? Regards, Markus ___ Cocci mailing list Cocci@systeme.lip6.fr

Re: [Cocci] [RFC PATCH 12/25] parsing_c: cpp_token_c: Introduce MACROANNOTATION hint

2020-04-24 Thread Markus Elfring
> A better way of denoting attributes is to pass attribute information > from SmPL to the C parser. Such information sounds promising. > However, a temporary solution is to introduce a MACROANNOTATION hint > to cpp_token_c.ml so that the parser can identify attributes easily. Have you got any

Re: [Cocci] [RFC PATCH 00/25] cocci: Improve C parsing of attributes

2020-04-24 Thread Markus Elfring
> This patch series aims to improve parsing of attributes in C by > Coccinelle's C parser. How do you think about to use the wording “in C source code by”? > These parsing errors were discovered by running a build of Coccinelle's Would you like to omit the word “These”? > Coccinelle

Re: [Cocci] console: Complete exception handling in newport_probe()

2020-04-24 Thread Markus Elfring
> Sorry, I do not know how to use the SmPL script. I would like to try again to make you more familiar with applications of the Coccinelle software.

Re: [Cocci] console: Complete exception handling in newport_probe()

2020-04-23 Thread Markus Elfring
> Please note you are responding to someone who many kernel maintainers, > myself included, have on their blacklist You configured your communication filters for some reasons in this way. > as they are totally unhelpful. The development views can vary also around my software contributions. It

Re: [Cocci] console: Complete exception handling in newport_probe()

2020-04-23 Thread Markus Elfring
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/log/scripts/coccinelle/free/iounmap.cocci … > Sorry, I do not know how to use the SmPL script. I proposed to take another look at the header of such a file. I imagine that provided information can trigger further development

Re: [Cocci] console: Complete exception handling in newport_probe()

2020-04-23 Thread Markus Elfring
>> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/log/scripts/coccinelle/free/iounmap.cocci >> >> How do you think about to extend presented software analysis approaches? >> > Sorry, I am not familiar with it, I don't know. Do you find the comments helpful at the beginning of

Re: [Cocci] [PATCH v1] console: fix an issue about ioremap leak.

2020-04-23 Thread Markus Elfring
> if do_take_over_console() return an error in the newport_probe(), > due to the io virtual address is not released, it will cause a leak. How do you think about a wording variant like the following? Subject: [PATCH v2] console: Complete exception handling in newport_probe() Change

Re: [Cocci] Combining isomorphisms with source code adjustments?

2020-04-22 Thread Markus Elfring
>> @deletion@ >> expression input, storage, target; >> @@ >> storage >> -= input >> ... when != storage >> target = ... >> >> >> elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch --parse-cocci >> delete_unused_value4.cocci >> … >> the simple assignment expression on line 4 contains

[Cocci] Combining isomorphisms with source code adjustments?

2020-04-22 Thread Markus Elfring
Hello, I have taken another look at the following information. https://github.com/coccinelle/coccinelle/blob/6b4bb692f208bfe86e62a616724570d9310c7150/standard.iso#L544 … // Affectation/initialisation isomorphism … // They are handled in engine. // 'X = Y' should also match 'type X = Y'; … I

Re: [Cocci] [V3] amdgpu: remove unnecessary condition check

2020-04-21 Thread Markus Elfring
>> But i have to say there are so many code not follow the kernel code-style in >> amdgpu module. >> And also the ./scripts/checkpatch.pl did not throw any warning or error. > > That is unfortunately true, yes. But we try to push new code through the > usual code review and improve things as we

Re: [Cocci] Function-like macro with the same name as a typedef

2020-04-20 Thread Markus Elfring
>> * How many software implementations use identical type definitions >> and function-like macros? > > I don't know. Can it become interesting to find more about such usage patterns out? > For what it's worth, it's valid C. Unless I'm mistaken, > Coccinelle tries to support as much of C as

Re: [Cocci] Function-like macro with the same name as a typedef

2020-04-20 Thread Markus Elfring
>>> * spatch seems to have trouble parsing >>> >>> ARMSSE *s = ARMSSE(opaque); >>> >>> where ARMSSE is a typedef, and ARMSSE() is a function-like macro. >>> Yes, I know that's in rather poor taste. >> >> I am curious for the safe handling of related software development >> challenges. >>

Re: [Cocci] Checking the replacement of two specific function calls

2020-04-20 Thread Markus Elfring
> Another possibility should be taken into account for source code variations. > > SmPL script example: > @replacement@ > expression base, device1, device2, index, private; > @@ > -private->res = platform_get_resource(device1, IORESOURCE_MEM, index); > base = > - devm_ioremap_resource > +

Re: [Cocci] [PATCH net-next v1] can: ti_hecc: convert to devm_platform_ioremap_resource_byname()

2020-04-19 Thread Markus Elfring
> use devm_platform_ioremap_resource_byname() to simplify code, > it contains platform_get_resource_byname() and > devm_ioremap_resource(), and also remove some duplicate error > message. How do you think about a wording variant like the following? Use the function

Re: [Cocci] Checking the replacement of two specific function calls

2020-04-17 Thread Markus Elfring
>> But I have now lost track of what the semantic patch actually is, >> so I don't know what is the problem. Another possibility should be taken into account for source code variations. SmPL script example: @replacement@ expression base, device1, device2, index, private; @@ -private->res =

Re: [Cocci] Checking the replacement of two specific function calls

2020-04-17 Thread Markus Elfring
> But I have now lost track of what the semantic patch actually is, > so I don't know what is the problem. Do you find the following transformation approach easier to clarify? SmPL script: @replacement@ expression base, device, index, private; @@ -private->res = platform_get_resource(device,

Re: [Cocci] Checking the replacement of two specific function calls

2020-04-17 Thread Markus Elfring
> OK, it seems that the structure is defined in the same file so no include > options should be needed. But I have now lost track of what the > semantic patch actually is, so I don't know what is the problem. 1. Unfortunately, I needed a bit longer to become more aware of relevant differences

Re: [Cocci] Checking the replacement of two specific function calls

2020-04-16 Thread Markus Elfring
>> Would I need any extra parameters here? > > Perhaps -I options to help it find the relevant .h file. The dependencies for the data structure “device” can become also more interesting. https://elixir.bootlin.com/linux/v5.7-rc1/source/include/linux/device.h#L451

Re: [Cocci] Checking the replacement of two specific function calls

2020-04-16 Thread Markus Elfring
>> Would I need any extra parameters here? > > Perhaps -I options to help it find the relevant .h file. I wonder why the relevant header files would not be found directly from the corresponding Git repository. Can a file inclusion failure become an immediate SmPL script execution error when a

Re: [Cocci] Checking the replacement of two specific function calls

2020-04-16 Thread Markus Elfring
> I don't think that there is any need for the * in the metavariable > declaration. I can try another SmPL script variant out also without the specification of an extra asterisk. If I test with the following source file example, a patch is generated by the Coccinelle software in the expected

Re: [Cocci] Checking the replacement of two specific function calls

2020-04-16 Thread Markus Elfring
>> elfring@Sonne:~/Projekte/Linux/next-patched> spatch >> --include-headers-for-types >> ~/Projekte/Coccinelle/janitor/use_devm_platform_get_and_ioremap_resource3.cocci >> drivers/i2c/busses/i2c-rcar.c > > No, include headers for types doesn't have any impact on how many header > files are

Re: [Cocci] Checking the replacement of two specific function calls

2020-04-16 Thread Markus Elfring
>> @replacement@ >> expression* base, device, resource; >> @@ >> -resource = platform_get_resource(device, IORESOURCE_MEM, 0); >> base = >> - devm_ioremap_resource(>dev, resource) >> + devm_platform_get_and_ioremap_resource(device, 0, ) >> ; … >> static int rcar_i2c_probe(struct

Re: [Cocci] Checking the replacement of two specific function calls

2020-04-15 Thread Markus Elfring
>> static int rcar_i2c_probe(struct platform_device *pdev) >> { >> struct rcar_i2c_priv *priv; … >> struct device *dev = >dev; >> // deleted part >> priv->res = platform_get_resource(pdev, IORESOURCE_MEM, 0); >> >> priv->io = devm_ioremap_resource(dev, priv->res); … >> } … >

[Cocci] Checking the replacement of two specific function calls

2020-04-15 Thread Markus Elfring
Hello, I noticed the suggestion “i2c: busses: convert to devm_platform_get_and_ioremap_resource”. https://lore.kernel.org/linux-i2c/20200414134827.18674-1-zhengdej...@gmail.com/ https://lore.kernel.org/patchwork/patch/1223734/ I got into the mood to try another script out for the semantic patch

<    1   2   3   4   5   6   7   8   9   10   >