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

2021-05-26 Thread Markus Elfring
> 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 > output of "git diff" and checks them against the specified > cocci script. > > An example for passing the "use-patchdiff" option is:

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

2021-05-05 Thread Markus Elfring
> v5: print a message with the new function name, as suggested by … Thanks for another small adjustment. Thus I find an other version number consistent in the patch subject. Do you care to influence the run time characteristics a bit more for such a script variant by reducing the number of SmPL

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

2021-04-29 Thread Markus Elfring
… > +msg = "WARNING: opportunity for pm_runtime_get_sync" > +coccilib.org.print_todo(j0[0], msg) … Do you find the following message variant more helpful? +coccilib.org.print_todo(j0[0], +"WARNING: opportunity for replacing pm_runtime_get_sync() by

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

2021-04-29 Thread Markus Elfring
>… keeps a reference count on failure, … Would you get into the mood to perform a systematic source code search for similar function implementations according to resource clean-up? > v2: better keyword How do you think about to add the information “wrapper functions” here? … > +@r0 depends

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

2021-04-26 Thread Markus Elfring
… > +// Keywords: kwd … Will any information become more helpful and succinct for such a SmPL script variant? Regards, Markus ___ Cocci mailing list Cocci@systeme.lip6.fr https://systeme.lip6.fr/mailman/listinfo/cocci

Re: [Cocci] Improve the handling of string literals with SmPL

2021-04-08 Thread Markus Elfring
> I'm asking you to put the regexp in a python function. Will it become easier and more convenient to search for string literals (and their exclusion according to the discussed transformation approach)? @initialize:python@ @@ def occurs(x): return '"' in x @display@ identifier i =~

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

2021-04-05 Thread Markus Elfring
>> 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 software functionality once more? > > There is perhaps

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

2021-04-05 Thread Markus Elfring
>> 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? The selection of the applied programming interfaces has got

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

2021-04-01 Thread Markus Elfring
>mac = of_get_mac_address(np); >if (!IS_ERR(mac)) > ether_addr_copy(ndev->dev_addr, mac); > > This would need to be changed to: > >of_get_mac_address(np, ndev->dev_addr); Can such a function call variant fail? How do you think about take any special return values into account?

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

2021-03-28 Thread Markus Elfring
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? https://github.com/coccinelle/coccinelle/issues/139 Regards, Markus

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

2021-03-28 Thread Markus Elfring
Hello, The Coccinelle software can search for header files in addition to source files if the option “--include-headers” was specified. https://github.com/coccinelle/coccinelle/blob/287374196da8c7cfd169e721a2d23f1e462422f1/docs/manual/spatch_options.tex#L43 How can it be achieved that only

Re: [Cocci] Checking evolution according to version 1.1.0

2021-02-28 Thread Markus Elfring
> A new version 1.1.0 has been released. Thanks. I have dared to activate also a current OCaml version by the command “opam switch create 4.12.0”. I have tried to rebuild your software accordingly. elfring@Sonne:~/Projekte/Coccinelle/20160205> make distclean && git checkout master && git pull

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

2021-02-16 Thread Markus Elfring
> +- tmp = a; > +- a = b; > +- b = tmp; > ++ swap(a, b); How do you think about to use the following SmPL code variant? * Omission of a few leading space characters * Keeping a semicolon unmodified in a line +-tmp = a; +-a = b; +-b = tmp ++swap(a, b) +; Regards, Markus

Re: [Cocci] [PATCH 1/3] kbuild: do not use scripts/ld-version.sh for checking spatch version

2020-12-13 Thread Markus Elfring
… > +++ b/scripts/coccicheck … > @@ -186,14 +185,11 @@ coccinelle () { … > +if [ -n "$REQ" ] && ! { echo "$REQ"; echo "$SPATCH_VERSION"; } | sort > -CV ; then Would it make sense to use an other command control operator? +if [ -n "$REQ" ] && ! { echo "$REQ" && echo "$SPATCH_VERSION"; }

Re: [Cocci] Checking the influence of an omitted semicolon on a code adjustment

2020-11-28 Thread Markus Elfring
> Why do you want to remove the semicolon? I have shown a transformation example where a function parameter should be replaced by a previous function call. Thus a semicolon should be intentionally be deleted. > If you want to find the call somewhere in the next statement, you can say > > ( > S

Re: [Cocci] Checking the influence of an omitted semicolon on a code adjustment

2020-11-28 Thread Markus Elfring
>> I have shown a transformation example where a function parameter should be >> replaced >> by a previous function call. >> Thus a semicolon should be intentionally be deleted. > > That makes no sense. This transformation part is working as expected (under constraints) already. > You can't

Re: [Cocci] Checking the influence of an omitted semicolon on a code adjustment

2020-11-28 Thread Markus Elfring
>>> You can't have an expression directly following a statement. >>> Only statements follow other statements. >> >> This information is reasonable. >> >> Does the Coccinelle software insist on the specification of another semicolon >> in the SmPL script for the identification of an adjustable

[Cocci] Checking the influence of an omitted semicolon on a code adjustment

2020-11-28 Thread Markus Elfring
Hello, The following small SmPL script gets successfully parsed by the Coccinelle software. @Replacement@ expression call, input, target; identifier gs; @@ -\( g_string_assign@gs \| g_string_append@gs \) (target, input); call ( - target + gs (target, input) ); But if I would

Re: [Cocci] [PATCH v2] coccinelle: locks: Add balancedlock.cocci script

2020-11-18 Thread Markus Elfring
> Changes in v2(as suggested by Markus): Thanks you picked a few suggestions up. I would appreciate further constructive clarifications. … > +++ b/scripts/coccinelle/locks/balancedlock.cocci … > +//# False positives may be generated due to locks released within a nested > +//# function call

Re: [Cocci] Checking the handling of spaces before opening parentheses for source code transformations

2020-11-05 Thread Markus Elfring
> If you want to ensure that your generated code has such properties, > you can use the argument --smpl-spacing. It is nice that code additions can be influenced by such a parameter. > If you want something more, you are welcome to implement it. I imagine that adjustments for matched

Re: [Cocci] Checking the handling of spaces before opening parentheses for source code transformations

2020-11-05 Thread Markus Elfring
> If you want to ensure that your generated code has such properties, you > can use the argument --smpl-spacing. Can there be a need for a related run time parameter for the handling of line breaks? Regards, Markus ___ Cocci mailing list

[Cocci] Checking the handling of spaces before opening parentheses for source code transformations

2020-11-05 Thread Markus Elfring
Hello, The coding style specification for C programs in GNOME contains also the following information. https://developer.gnome.org/programming-guidelines/stable/c-coding-style.html.en#whitespace “… Always put a space before an opening parenthesis but never after: …” How good can the semantic

Re: [Cocci] Coccinelle: Checking the relevance of parentheses in “git grep”

2020-10-27 Thread Markus Elfring
>> … git grep -l -w \( -e for_each_node_by_type … -e >> for_each_node_with_property \) -- '*.c' >> >> >> How do you think about to omit these parentheses here? > > Does it make a difference? I find that it can be nicer to avoid the passing of unnecessary characters. * The compilation of the

Re: [Cocci] Coccinelle: Checking the relevance of parentheses in “git grep”

2020-10-27 Thread Markus Elfring
> Will any adjustments become relevant then accordingly? I have found out that the function “interpret” (OCaml code) constructs a command and executes it. https://github.com/coccinelle/coccinelle/blob/3c01dc1696dc5ccfb319673f205e491b572ee0be/parsing_cocci/git_grep.ml#L9 I have tried a

Re: [Cocci] Coccinelle: null: Optimise disjunctions in SmPL script “eno.cocci”

2020-10-25 Thread Markus Elfring
>> This analysis result indicates a clear ranking for such function calls. >> Thus reorder the SmPL disjunction items according to their usage incidence. > > Did you actually test this before and after the change and see a > difference in performance? Would you become interested to configure a

Re: [Cocci] Coccinelle: null: Optimise disjunctions in SmPL script “eno.cocci”

2020-10-25 Thread Markus Elfring
>> Would you become interested to configure a representative test environment >> for safe comparisons of corresponding run time characteristics >> of the affected software? > > In what sense could the comparison possibly be unsafe? * Our test systems are obviously different. Thus concerns can

[Cocci] [PATCH] Coccinelle: api: Optimise disjunction in SmPL script “pm_runtime.cocci”

2020-10-25 Thread Markus Elfring
From: Markus Elfring Date: Sun, 25 Oct 2020 14:10:58 +0100 A disjunction is applied by this script for the semantic patch language. This construct uses short-circuit evaluation. It has got the consequence that the last element of the specified condition will only be checked if all previous parts

Re: [Cocci] Coccinelle: null: Optimise disjunctions in SmPL script “eno.cocci”

2020-10-25 Thread Markus Elfring
> In the patch case, the user and system time are essentially identical. > In the context case, the difference in user time is 2 seconds out of 9.5 > minutes, 0.3%. This was just a single test run example. > In the patch case, the real time is a bit slower. I wonder about such an

[Cocci] [PATCH] Coccinelle: null: Optimise disjunctions in SmPL script “eno.cocci”

2020-10-25 Thread Markus Elfring
From: Markus Elfring Date: Sun, 25 Oct 2020 18:54:36 +0100 A disjunction is applied by this script for the semantic patch language. This construct uses short-circuit evaluation. It has got the consequence that the last element of the specified condition will only be checked if all previous parts

Re: [Cocci] Adjusting replacement lists with SmPL?

2020-10-23 Thread Markus Elfring
I'd like to add a statement after another within a preprocessor expression, How do you think about to refer to a “#define directive”? but spatch adds the line without an escape (backslash). I imagine that we stumble on another target conflict here.

Re: [Cocci] Determination of an usage statistic for memory allocation calls

2020-10-18 Thread Markus Elfring
> > Can such facts influence the specification of efficient SmPL disjunctions > > another bit? > > On my machine, putting the three functions that you have foudn to be the > most frequent at the end of each disjunction has no impact on the performance. I propose to reconsider this view. > So

Re: [Cocci] Determination of an usage statistic for memory allocation calls

2020-10-18 Thread Markus Elfring
> … > > +E = \(kmalloc\|kzalloc\|krealloc\|kcalloc\| > > + kmalloc_node\|kzalloc_node\|kmalloc_array\| > > + kmalloc_array_node\|kcalloc_node\)(...)@kok > … > > How do you think about the possibility for any adjustments according to the > order > of the mentioned function

Re: [Cocci] Determination of an usage statistic for macro calls “for_each…node…”

2020-10-18 Thread Markus Elfring
> Would you like to look for software configuration alternatives for better > parallel data processing? I would like to share another source code analysis approach. I hope that this contribution can trigger further helpful software development ideas. @initialize:python@ @@ import sys def

Re: [Cocci] Determination of an usage statistic for macro calls “for_each…node…”

2020-10-17 Thread Markus Elfring
> … > > +( > > +for_each_node_by_name(n,e1) S > > +| > … > > +| > > +for_each_node_with_property(n,e1) S > > +) > … > > > Do you indicate any occurrence frequencies or probabilities for the mentioned > macro calls > by the ordering in this disjunction for the semantic patch language? I would

Re: [Cocci] [PATCH v8] coccinelle: api: add kfree_mismatch script

2020-10-17 Thread Markus Elfring
> > How do you think about the possibility for any adjustments according to the > > order > > of the mentioned function names in proposed disjunctions for the semantic > > patch language? > > Please think about this for 5 seconds. Maybe there are 2000 calls to > these allocation functions, and

Re: [Cocci] [PATCH v8] coccinelle: api: add kfree_mismatch script

2020-10-16 Thread Markus Elfring
… > +E = \(kmalloc\|kzalloc\|krealloc\|kcalloc\| > + kmalloc_node\|kzalloc_node\|kmalloc_array\| > + kmalloc_array_node\|kcalloc_node\)(...)@kok … How do you think about the possibility for any adjustments according to the order of the mentioned function names in proposed

[Cocci] Explanation for kinds of SmPL rules

2020-09-27 Thread Markus Elfring
Hello, The manual for the semantic patch language mentions the grammar item “rulekind”. https://github.com/coccinelle/coccinelle/blob/730dbb034559b3e549ec0b2973cd0400a3fa072f/docs/manual/cocci_syntax.tex#L116 I would appreciate further information for the safe application of such a technical

Re: [Cocci] [PATCH] coccinelle: iterators: Add for_each_child.cocci script

2020-09-24 Thread Markus Elfring
> +@ruletwo depends on patch && !context && !org && !report@ How do you think about to combine code from two SmPL rules by using another SmPL disjunction like the following? @addition_rule depends on patch && !context && !org && !report@ local idexpression r.n; expression e,e1; expression list

[Cocci] [PATCH] Coccinelle: api: Add SmPL script “use_platform_get_irq.cocci”

2020-09-24 Thread Markus Elfring
From: Markus Elfring Date: Wed, 23 Sep 2020 18:30:25 +0200 A wrapper function is available since the commit 7723f4c5ecdb8d832f049f8483beb0d1081cedf6 ("driver core: platform: Add an error message to platform_get_irq*()"). Provide design options for the adjustment of affected s

Re: [Cocci] [PATCH] coccinelle: iterators: Add for_each_child.cocci script

2020-09-24 Thread Markus Elfring
> +// Confidence: High Will an addition like the following be helpful? +// Options: --no-includes --include-headers > +@r@ > +local idexpression n; > +expression e1,e2; > +iterator name for_each_node_by_name, for_each_node_by_type, > +for_each_compatible_node, for_each_matching_node, >

Re: [Cocci] Checking adjustments for pointer resets with SmPL

2020-09-21 Thread Markus Elfring
> I have noticed the update suggestion “USB: quirks: simplify quirk handling”. > https://lore.kernel.org/linux-usb/20200921113039.ga19...@duo.ucw.cz/ > https://lore.kernel.org/patchwork/patch/1308991/ I would like to point out that an acceptable patch can be generated for the implementation of

[Cocci] Checking adjustments for pointer resets with SmPL

2020-09-21 Thread Markus Elfring
Hello, I have noticed the update suggestion “USB: quirks: simplify quirk handling”. https://lore.kernel.org/linux-usb/20200921113039.ga19...@duo.ucw.cz/ https://lore.kernel.org/patchwork/patch/1308991/ Thus I converted a patch hunk into the following script variant for the semantic patch

[Cocci] Searching for functions with non-internal linkage

2020-09-21 Thread Markus Elfring
Hello, I have tried another tiny script variant out for the semantic patch language (according to the software combination “Coccinelle 1.0.8-00177-g28737419”). @find@ identifier i; type t; @@ t i(...) { ... } @find_static@ identifier find.i; type find.t; @@ static t i(...) { ... } @display

Re: [Cocci] [RFC PATCH] scripts: coccicheck: Improve error feedback when coccicheck fails

2020-09-14 Thread Markus Elfring
… > +++ b/scripts/coccicheck > @@ -126,8 +126,14 @@ run_cmd_parmap() { > if [ $VERBOSE -ne 0 ] ; then > echo "Running ($NPROC in parallel): $@" > fi > - echo $@ >>$DEBUG_FILE > - $@ 2>>$DEBUG_FILE > + if [ "$DEBUG_FILE" != "/dev/null" -a "$DEBUG_FILE" != "" ];

Re: [Cocci] [RFC PATCH 1/3] parsing_c: includes_cache: Implement a name cache

2020-09-09 Thread Markus Elfring
> Implement a name cache and includes dependency graph to optimize > performance for recursive parsing of header files. Can such information trigger any more evolution besides the contributed OCaml source code? > The names of the above are stored in a "name cache", i.e. a hashtable > to map

Re: [Cocci] [RFC PATCH 0/3] parsing_c: Optimize recursive header file parsing

2020-09-09 Thread Markus Elfring
> This patch series aims to optimize performance for recursively parsing > header files in Coccinelle. I am curious how you got encouraged to pick such a software development challenge up. > it would take close to 7 hours to complete. This is unfortunate. How do you think about to offer any

Re: [Cocci] [PATCH v2] scripts: coccicheck: Do not use shift command when rule is specified

2020-09-09 Thread Markus Elfring
> Modify coccicheck to use the shift command only when > number of shell arguments is not zero. I suggest to add the tag “Fixes” to the commit message. > Changes in V2: > - Fix spelling errors as suggested by Markus Elfring Would you like to adjust the last word in the pr

[Cocci] [PATCH v2] Coccinelle: api: Add SmPL script “use_devm_platform_get_and_ioremap_resource.cocci”

2020-09-07 Thread Markus Elfring
From: Markus Elfring Date: Mon, 7 Sep 2020 18:38:04 +0200 Another wrapper function is available since the commit 890cc39a879906b63912482dfc41944579df2dc6 ("drivers: provide devm_platform_get_and_ioremap_resource()"). Provide safe design options for the adjustment of affected s

Re: [Cocci] [PATCH] Coccinelle: api: Add SmPL script “use_devm_platform_get_and_ioremap_resource.cocci”

2020-09-07 Thread Markus Elfring
>> +@display depends on context@ >> +expression base, device1, device2, index, private, resource; >> +@@ >> +( >> +*resource = platform_get_resource(device1, IORESOURCE_MEM, index); >> + base = >> +* devm_ioremap_resource >> + (>dev, resource); > > Why do you

[Cocci] [PATCH] Coccinelle: api: Add SmPL script “use_devm_platform_get_and_ioremap_resource.cocci”

2020-09-07 Thread Markus Elfring
From: Markus Elfring Date: Mon, 7 Sep 2020 13:14:44 +0200 Another wrapper function is available since the commit 890cc39a879906b63912482dfc41944579df2dc6 ("drivers: provide devm_platform_get_and_ioremap_resource()"). Provide design options for the adjustment of affected source code by

Re: [Cocci] [PATCH] coccinelle: ifnullfree: add vfree(), kvfree*() functions

2020-09-02 Thread Markus Elfring
> Extend the list of free functions with kvfree(), kvfree_sensitive(), > vfree(). How do you think about further software extensions for this source code search pattern? Another example for a corresponding advanced data processing approach:

Re: [Cocci] transform oddity

2020-08-30 Thread Markus Elfring
> Is it me not understanding cocci grammar again? You are also struggling with expressing your data processing needs by the means of the semantic patch language. You would like to rename three parameters for selected functions. I imagine that an other transformation specification will be more

Re: [Cocci] [RFC PATCH] coccinelle: api: add flex_array_size.cocci script

2020-08-29 Thread Markus Elfring
> Suggest flex_array_size() wrapper to compute the size of a > flexible array member in a structure. The macro additionally > checks for integer overflows. Can the following script variant for the semantic patch language help to clarify any software development ideas and remaining open issues?

Re: [Cocci] Checking the application of a SmPL disjunction for a function call addition

2020-08-29 Thread Markus Elfring
>> Will this information trigger further consequences for the clarification >> of the topic “[RFC PATCH] coccinelle: api: add flex_array_size.cocci script”? >> https://lore.kernel.org/cocci/20200828163134.496386-1-efre...@linux.com/ >>

Re: [Cocci] Checking the application of a SmPL disjunction for a function call addition

2020-08-29 Thread Markus Elfring
>> @replacement@ >> identifier array, instance, size; >> type T; >> @@ >> ( >> -sizeof(T) >> | >> -sizeof(*instance->array) >> ) >> * >> +flex_array_size(instance, array, >> instance->size >> + ) > > This semantic patch will fail if the sizeof(T) option is matched,

[Cocci] Checking the deletion of a multiplication operator with SmPL

2020-08-29 Thread Markus Elfring
Hello, The following small script variant for the semantic patch language gets accepted according to the software combination “Coccinelle 1.0.8-00159-g730dbb03”. @replacement@ identifier array, instance, size; type T; @@ ( -sizeof(T) | -sizeof(*instance->array) ) * +flex_array_size(instance,

[Cocci] Checking the usage of a SmPL disjunction within a sizeof()

2020-08-28 Thread Markus Elfring
Hello, I have tried another tiny script variant out for the semantic patch language (according to the software combination “Coccinelle 1.0.8-00159-g730dbb03”). @display@ identifier array, instance; type T; @@ *sizeof( \( T \| *(instance->array) \) ) elfring@Sonne:~/Projekte/Coccinelle/Probe>

Re: [Cocci] coccinelle: Convert comma to semicolon

2020-08-21 Thread Markus Elfring
> > Add an imperfect test to detect these comma uses. > > > > No false positives were found in testing, but many types of false negatives > > are possible. > > > > e.g.: > > foo = bar() + 1,/* comma use, but not direct assignment */ > > bar = baz(); > > Hi. > > I recently added a

Re: [Cocci] coccinelle: api: add sprintf() support to device_attr_show

2020-08-17 Thread Markus Elfring
> The problem has nothing to do with disjunctions. Can missing source code matches trigger the consequence that questionable branches would be applied there? Will the clarification for the issue “failing tests - TODO” be continued? Regards, Markus ___

Re: [Cocci] coccinelle: api: add sprintf() support to device_attr_show

2020-08-17 Thread Markus Elfring
> I will see if it can be fixed. How will the issue “failing tests - TODO” evolve further? https://github.com/coccinelle/coccinelle/commit/f2d7ec9006c89610bd1aab4662fcf100e3e6d469#diff-13ff769079511ec7b5dddef7143b2b93R1 How do the comments there fit to undesirable effects for SmPL disjunctions?

Re: [Cocci] Searching for format strings with SmPL disjunctions

2020-08-16 Thread Markus Elfring
How do you think about to extend a source code search pattern like the following by using a regular expression as a SmPL constraint? @display@ format F =~ "l{0,2}[diuxX]"; @@ *\("%@F@" \| "%@F@\n"\) Regards, Markus ___ Cocci mailing list

Re: [Cocci] Searching for format strings with SmPL disjunctions

2020-08-16 Thread Markus Elfring
> There are no short term plans for this. Can long term development considerations be influenced for advanced data processing of format strings? Regards, Markus ___ Cocci mailing list Cocci@systeme.lip6.fr

Re: [Cocci] Searching for format strings with SmPL disjunctions

2020-08-16 Thread Markus Elfring
Can a source code search pattern like the following become ever usable? @display@ @@ *"%" ("d" |"ld" |"lld" ) ("\n" |"" ) elfring@Sonne:~/Projekte/Coccinelle/Probe> spatch --parse-cocci show_usage_of_selected_format_strings.cocci … minus: parse error: File

[Cocci] [PATCH v2] drm/nouveau/gem: Use vmemdup_user() rather than duplicating its implementation

2020-08-14 Thread Markus Elfring
From: Markus Elfring Date: Fri, 14 Aug 2020 08:56:54 +0200 * Reuse existing functionality from vmemdup_user() instead of keeping duplicate source code. Generated by: scripts/coccinelle/api/memdup_user.cocci * See also: [PATCH] drm/nouveau/gem: fix err_cast.cocci warnings * Simplify

Re: [Cocci] [PATCH v3] documentation: coccinelle: Improve command example for make C={1, 2}

2020-08-10 Thread Markus Elfring
> the usage of the makefile C variable flag by coccicheck. * Can it be confusing to denote an item as a variable and a flag? * Would you really like to stress here that a flag can be variable? > +This variable can be used to run scripts for … Can the scope for a make command be selected also

[Cocci] [PATCH] Coccinelle: Reduce duplicate code for patch rules of memdup_user.cocci

2020-08-10 Thread Markus Elfring
From: Markus Elfring Date: Sun, 9 Aug 2020 11:11:20 +0200 Another patch rule was added. A bit of code was copied from a previous SmPL rule for this change specification. * Thus reduce duplicate code by using another SmPL disjunction. * Increase the precision a bit for desired source code

Re: [Cocci] [PATCH v2] documentation: coccinelle: Improve command example for make C={1, 2}

2020-08-10 Thread Markus Elfring
> Modify coccinelle documentation to further clarify > the usage of the makefile C variable flag by coccicheck. How do you think about a wording variant like the following for the change description? Clarify the usage of the make variable “C” for coccicheck. > +C flag is used. The C flag is

Re: [Cocci] [PATCH 42/43] tests: Add test case to match meta attribute

2020-07-26 Thread Markus Elfring
… > +++ b/tests/metaattr.cocci > @@ -0,0 +1,9 @@ > +@@ > +attribute name __attr__; > +attribute a; > +identifier b; > +@@ > + > +-int > ++char > + b a = 1; I have got understanding difficulties for this test SmPL script. I interpret such SmPL code in the way that the metavariable

Re: [Cocci] [PATCH 42/43] tests: Add test case to match meta attribute

2020-07-26 Thread Markus Elfring
… > +++ b/tests/metaattr.c > @@ -0,0 +1,5 @@ > +int main() { > + int b __attr__ = 1; > + int b = 1; > + return 0; > +} * Should such test code really work with a repeated definition of the variable “b”? * Would you like to test here if the identifier “b” should be handled as an

[Cocci] [PATCH] Coccinelle: Add a SmPL script for the reconsideration of function calls before return statements

2020-07-08 Thread Markus Elfring
From: Markus Elfring Date: Wed, 8 Jul 2020 19:09:59 +0200 It can happen that function implementations with the return type “void” call a special function at the end of if branches. Such calls are occasionally followed by an immediate return. The same function can be called at the end

[Cocci] Adding labels without indentation before specific statements?

2020-07-07 Thread Markus Elfring
Hello, I have tried another tiny script variant out for the semantic patch language (according to the software combination “Coccinelle 1.0.8-00139-gd0fd4c7d”). @addition@ identifier work; expression action; @@ void work(...) { ... when any +last_action: action(...); } Such a simple

[Cocci] Checking data processing results for a special SmPL disjunction

2020-06-27 Thread Markus Elfring
Hello, I have tried another tiny script variant out for the semantic patch language (according to the software combination “Coccinelle 1.0.8-00131-g675b9670”). @display@ expression* pointer; identifier result; type t; @@ t result = <+... ( sizeof(*(pointer)) | * *(pointer) )

Re: [Cocci] Checking the parsing for a nested SmPL disjunction

2020-06-26 Thread Markus Elfring
I assumed that I may omit the semicolon in such a SmPL code. Can the specification of a SmPL nest construct ever be sufficient here? >>> >>> No. <+... ...+> matches a subtree of an AST. For a variable >>> initialization, there is no subtree of the AST that includes both the >>> right

Re: [Cocci] Checking the parsing for a nested SmPL disjunction

2020-06-26 Thread Markus Elfring
>> I assumed that I may omit the semicolon in such a SmPL code. >> Can the specification of a SmPL nest construct ever be sufficient here? > > No. <+... ...+> matches a subtree of an AST. For a variable > initialization, there is no subtree of the AST that includes both the > right side of an =

Re: [Cocci] Checking the parsing for a nested SmPL disjunction

2020-06-26 Thread Markus Elfring
>> <+... when any >> (t2 y = <+... >> ( sizeof(*(resource)) >> | >> * *(resource) >> ) ...+> > > You are missing a ; here. I assumed that I may omit the semicolon in such a SmPL code. Can the specification of a SmPL nest construct ever be sufficient here? Regards, Markus

[Cocci] Checking the parsing for a nested SmPL disjunction

2020-06-26 Thread Markus Elfring
Hello, I have tried another small script variant out for the semantic patch language (according to the software combination “Coccinelle 1.0.8-00131-g675b9670”). @display@ type t1, t2; expression action; identifier resource, y; statement is, es; @@ t1* resource; <+... when any (t2 y = <+... (

[Cocci] Checking the display of SmPL isomorphism results (with pointers)

2020-06-26 Thread Markus Elfring
Hello, I have tried another tiny script variant out for the semantic patch language (according to the software combination “Coccinelle 1.0.8-00131-g675b9670”). @display@ expression* x; statement is, es; @@ *if (!x) is else es elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch

[Cocci] Checking the parsing for a specific SmPL disjunction

2020-06-25 Thread Markus Elfring
Hello, I know that the following SmPL script example gets accepted by the Coccinelle software. @display@ expression x, y; @@ *y = ... *(x) ... I have tried another tiny script variant out for the semantic patch language (according to the software combination “Coccinelle

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

2020-06-17 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 >>>

Re: [Cocci] [PATCH] coccinelle: misc: add array_size_dup script to detect missed overflow checks

2020-06-17 Thread Markus Elfring
> ( > * size = E1 * E2;@p > | > * size = E1 * E2 * E3;@p > | > * size = E1 * E2 + E3;@p > ) I suggest to reconsider also the order of elements for such a SmPL disjunction. Can a computation like “E2 * E3” also be matched by the expression metavariable “E2” alone? Regards, Markus

Re: [Cocci] [PATCH] coccinelle: misc: Add array_size_dup script to detect missed overflow checks

2020-06-17 Thread Markus Elfring
I propose once more to avoid a typo in the previous patch subject. … > ( > - size = E1 * E2; > + size = array_size(E1, E2); > | > - size = E1 * E2 * E3; > + size = array3_size(E1, E2, E3); > | > - size = E1 * E2 + E3; > + size = struct_size(E1, E2, E3); > ) How do you think about to use SmPL

Re: [Cocci] Software analysis around data type annotations

2020-06-17 Thread Markus Elfring
>> I am going to present similar questions occasionally. > > Please stop. I hope that I can continue as usual for while according to a desire to achieve further improvements. > The chance that people will help you will increase. This would be nice. > No one is interested in quantifying

Re: [Cocci] Software analysis around data type annotations

2020-06-17 Thread Markus Elfring
> *void * __iomem action(...) > {...} > > It's not quite in line with the what-you-see-is-what-you-get principle, > but it'll work for your use case. Usable output is produced after the adjusted position for the macro. elfring@Sonne:~/Projekte/Linux/next-patched> spatch

Re: [Cocci] Software analysis around data type annotations

2020-06-17 Thread Markus Elfring
> I'm away from my computer right now so can't test this, but try declaring > __iomem as an attribute: @display@ attribute name __iomem; identifier action; @@ *void __iomem * action(...) { ... } elfring@Sonne:~/Projekte/Coccinelle/janitor> spatch --parse-cocci show_iomem_functions2.cocci …

[Cocci] Software analysis around data type annotations

2020-06-16 Thread Markus Elfring
Hello, The support for data processing with attributes was extended recently. https://github.com/coccinelle/coccinelle/commits?q=committer-date%3A%3C2020-06-16 Under which circumstances will a source code analysis approach become supported by a script (like the following) for the semantic patch

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

2020-06-15 Thread Markus Elfring
>> +virtual report, org, context, patch >> >> Is such a SmPL code variant more succinct? > > This doens't matter. Can less duplicate code be a bit nicer? >>> +ssize_t show(struct device *dev, struct device_attribute *attr, char *buf) >>> +{ >>> + <... >>> +* return snprintf@p(...); >>> +

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

2020-06-15 Thread Markus Elfring
> +// Confidence: High Would you like to add any suggestion for a possible patch message? … > +virtual report > +virtual org > +virtual context > +virtual patch +virtual report, org, context, patch Is such a SmPL code variant more succinct? … > +ssize_t show(struct device *dev, struct

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

2020-06-15 Thread Markus Elfring
… > +virtual context > +virtual patch > +virtual org > +virtual report +virtual context, patch, org, report Is such a SmPL code variant more succinct? … > +if (...) > + \(memset@ok\|memzero_explicit@ok\)(...); Would you like to tolerate any extra source code around such a function call in an

Re: [Cocci] [PATCH] coccinelle: misc: add array_size_dup script to detect missed overflow checks

2020-06-15 Thread Markus Elfring
I suggest to avoid a typo in the previous patch subject. … > +virtual context > +virtual report > +virtual org +virtual context, report, org Is such a SmPL code variant more succinct? … > +@as_next@ > +expression subE1 <= as.E1; > +expression as.E1; … I propose to reduce the repetition of

Re: [Cocci] coccinelle issues

2020-06-14 Thread Markus Elfring
> > Note2: https://github.com/coccinelle/coccinelle/blob/master/install.txt > > says that 'spatch' is a script, but it seems to be a binary executable file. > > Actually, it is a script, and the fact that you say it is a binary may be > the reason for your python problem. Normally there is a

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

2020-06-14 Thread Markus Elfring
> … Looks like it's impossible to break "when" lines. Thus I became also curious on clarification for further software development possibilities around the safer application of code exclusion specifications by the means of the semantic patch language. Regards, Markus

Re: [Cocci] [PATCH 1/3] parsing_cocci: arity: Apply mcode2arity on macrodecl/param attrs

2020-06-12 Thread Markus Elfring
> The following commits introduced some poor management of attributes in arity.ml: > 08f1cd9fb83ec400435e0ad8fdf579ec8f9c0f21 > b4b8653bd5a9607922e0050fe2fede10d422b218 I suggest to specify also subjects for such commit references. > Apply mcode2arity to macrodecl and parameter

Re: [Cocci] Checking software behaviour according to selected SmPL code variants

2020-06-10 Thread Markus Elfring
>> @display@ >> expression e; >> @@ >> *brelse(e); >> <+... when != e = ... >> (e = ... >> | >> *e >> )...+> >> >> >> I would find it nicer if I do not need to repeat a code exclusion >> specification >> as the first element of a SmPL disjunction for this special use case. > > You don't. The

Re: [Cocci] Checking software behaviour according to selected SmPL code variants

2020-06-10 Thread Markus Elfring
>> I hoped that my specification of a SmPL code exclusion should prevent >> the presentation of assignments (independent from statements and/or >> expressions). > > ( > e = e1 > | > *e > ) @display@ expression e; @@ *brelse(e); <+... when != e = ... (e = ... | *e )...+> I would find it nicer

Re: [Cocci] Checking software behaviour according to selected SmPL code variants

2020-06-10 Thread Markus Elfring
>> @display@ >> expression e; >> @@ >> *brelse(e); >> <+... when != e = ... >> *e >> ...+> … >> elfring@Sonne:~/Projekte/Linux/next-patched> spatch >> ~/Projekte/Coccinelle/janitor/show_questionable_brelse_usage8.cocci >> fs/ext4/extents.c >> … >> @@ -1127,8 +1121,6 @@ static int

Re: [Cocci] Checking software behaviour according to selected SmPL code variants

2020-06-10 Thread Markus Elfring
> That is quite normal. One statement should be followed by another statement. I have tried another script variant out for the semantic patch language. @display@ expression e; @@ *brelse(e); <+... when != e = ... *e ...+> I wonder about the generation of a diff hunk then like the

Re: [Cocci] Checking software behaviour according to selected SmPL code variants

2020-06-09 Thread Markus Elfring
>> If I omit the specification “, ...” from the function call parameters >> because I could be unsure about the number of arguments in other >> software situations, I do not get the desired test output as before. > > This has been discussed before. I was just looking for a related update in this

[Cocci] Checking software behaviour according to selected SmPL code variants

2020-06-09 Thread Markus Elfring
Hello, My software development attention was caught also by a recent patch. https://lore.kernel.org/linux-fsdevel/20200608141629.GA1912173@mwanda/ https://lore.kernel.org/patchwork/patch/1253499/ Thus I have tried another tiny script out for the semantic patch language (according to the software

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

2020-06-09 Thread Markus Elfring
… > +++ b/scripts/coccinelle/api/memdup_user.cocci > @@ -20,7 +20,9 @@ expression from,to,size; … > +- to = \(kmalloc\|kzalloc\) > + (size,\(GFP_KERNEL\|GFP_USER\| > + \(GFP_KERNEL\|GFP_USER\)|__GFP_NOWARN\)); I got the impression that this SmPL code needs another

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

2020-06-09 Thread Markus Elfring
… > +++ b/scripts/coccinelle/api/memdup_user.cocci > @@ -14,13 +14,24 @@ virtual patch > virtual context > virtual org > virtual report > +virtual selfcheck Would you like to avoid the repetition of a SmPL key word here? +virtual patch, context, org, report, selfcheck > @@ -117,3 +128,34 @@

  1   2   3   4   5   6   7   8   9   10   >