Re: [Cocci] Pretty-printing of code for ternary operators?

2019-07-04 Thread Markus Elfring
>> Would you like to achieve any improvements for automatic code beautification? >> https://github.com/coccinelle/coccinelle/issues/37 > > If you want to report a problem, I became curious again if more contributors would become interested to influence a possibly known software situation a bit

[Cocci] Pretty-printing of code for ternary operators?

2019-07-04 Thread Markus Elfring
Hello, The semantic patch language supports also to convert conditional statements into usages of the ternary operator. How much can the Coccinelle software help with pretty-printing of generated source code in this area? Would you like to achieve any improvements for automatic code

Re: [v2] coccinelle: semantic code search for missing of_node_put

2019-07-04 Thread Markus Elfring
> We tested and found that both <...x...> and <+... x ...+> variants work fine. Is the difference in the functionality from this SmPL construct clear already? > We use <... x ...> instead of <+... x ...+> here to eliminate the following > false positives: Do we stumble on another software

Re: [v2] coccinelle: semantic code search for missing of_node_put

2019-07-03 Thread Markus Elfring
> We will also provide an example written in Python later. Will the code move from the commit description into a file for your next patch version? > We first use this script to find out all the function names to be processed, I am still curious on how the output format selection will become

Re: [v2] Coccinelle: Suppression of warnings?

2019-07-01 Thread Markus Elfring
> By the way: do we have any mechanism for explicitly suppressing > individual warnings (some kind of annotation), I do not know such an accepted specification interface (for the handling together with SmPL scripts) so far. How would you identify possibly unwanted messages in a safe way? > when

[PATCH v2] Coccinelle: Add a SmPL script for the reconsideration of redundant dev_err() calls

2019-07-01 Thread Markus Elfring
From: Markus Elfring Date: Mon, 1 Jul 2019 10:00:39 +0200 The function “devm_ioremap_resource” contains appropriate error reporting. Thus it can be questionable to present another error message at other places. Provide design options for the adjustment of affected source code by the means

Re: [v2] Coccinelle: Testing SmPL constraints

2019-06-29 Thread Markus Elfring
> Please actually try things out before declaring them to be useless. This feedback provides also another opportunity for collateral evolution in some directions. I am curious on how involved uncertainty can be fixed around possibly different interpretation for provided software functionality.

Re: [v2] coccinelle: semantic code search for missing of_node_put

2019-06-29 Thread Markus Elfring
+if (x == NULL || ...) S +... when != e = (T)x +when != true x == NULL … > I assume that it was added because it was found to be useful. We can get different software development opinions also on this implementation detail. > Please actually try things out before declaring

Re: [v2] coccinelle: semantic code search for missing of_node_put

2019-06-29 Thread Markus Elfring
>> +if (x == NULL || ...) S >> +... when != e = (T)x >> +when != true x == NULL > > I wonder if this code exclusion specification is really required > after a null pointer was checked before. I would like to add another view for this implementation detail. The when constraint can express a

Re: [v2] coccinelle: semantic code search for missing of_node_put

2019-06-28 Thread Markus Elfring
>> +x = >> +(of_… >> +|of_… >> +)@p1(...); > > Did you actually test this? I doubt that a position metavariable can be > put on a ) of a disjunction. Would you ever like to support this possibility? >> +|return >> +(x >> +|of_fwnode_handle(x) >> +); > > The original code is much more readable.

Re: [v2] coccinelle: semantic code search for missing of_node_put

2019-06-28 Thread Markus Elfring
>> +x = >> +(of_… >> +|of_… >> +)@p1(...); > > Did you actually test this? I doubt that a position metavariable can be > put on a ) of a disjunction. Would you ever like to support this possibility? >> +|return >> +(x >> +|of_fwnode_handle(x) >> +); > > The original code is much more readable.

Re: [PATCH v2] coccinelle: semantic code search for missing of_node_put

2019-06-28 Thread Markus Elfring
> The counter must be decremented after the last usage of a device node. Thanks for your next try to improve the software situation also in this area. > We find these functions by using the following SmPL: Would it be nicer to use the word “script” also here? > > @initialize:ocaml@ > @@

Re: [Cocci] Moving exception handling code to the end of a function implementation with SmPL?

2019-06-27 Thread Markus Elfring
>> Where did the Coccinelle software get the impression that anything >> would be added too often at the end of such a function implementation? > > Without the semantic patch and the C source code, You have access to data from both files already. > I can't answer the question. Is it more

Re: [Cocci] Moving exception handling code to the end of a function implementation with SmPL?

2019-06-27 Thread Markus Elfring
>> replacement: already tagged token: > > You try to add two things one one token, which is not allowed. How do you think about to clarify why a source file adjustment like the following can let my SmPL script succeed in a test configuration? elfring@Sonne:~/Projekte/Coccinelle/Probe> diff -u

Re: [Cocci] Moving exception handling code to the end of a function implementation with SmPL?

2019-06-27 Thread Markus Elfring
>>> You can try with the option --debug. >>> Or if that doesn't help with the option --verbose-ctl-engine. >> >> How can these parameters help to clarify undesirable run time >> characteristics? > > How about actually looking at the results yourself? I did that. - I do not find these extra data

Re: [Cocci] Moving exception handling code to the end of a function implementation with SmPL?

2019-06-27 Thread Markus Elfring
> Maybe there are too many metavariable bindings. Under which circumstances would such a situation really occur? How do you think about my SmPL script example for the shown use case? > You can try with the option --debug. > Or if that doesn't help with the option --verbose-ctl-engine. How can

Re: [Cocci] Moving exception handling code to the end of a function implementation with SmPL?

2019-06-27 Thread Markus Elfring
> * The complete source file seems to be very challenging for testing > the run time characteristics. How are the chances to clarify the different test results for this source code transformation approach with the software combination “Coccinelle 1.0.7-00211-geaa13d59-dirty (OCaml 4.07.1)”?

Re: [Cocci] More precise distinction of types for source code searches?

2019-06-26 Thread Markus Elfring
> @@ > expression x; > constant c1,c2; > @@ > > x = c1; The SmPL manual contains the promising wording “As metavariables are bound and inherited across rules, …”. https://github.com/coccinelle/coccinelle/blob/c6d7554edf7c4654aeae4d33c3f040e300682f23/docs/manual/cocci_syntax.tex#L179 The

Re: [Cocci] More precise distinction of types for source code searches?

2019-06-25 Thread Markus Elfring
> @@ > expression x; > constant c1,c2; > @@ > > x = c1; > ( > x = c1; > | > *x = c2; > ) Thanks for your suggestion of the possible usage of a SmPL disjunction. * Does it indicate a search attempt to match the first assignment statement twice (for the implementation of exclusion of duplicate

Re: [Cocci] More precise distinction of types for source code searches?

2019-06-25 Thread Markus Elfring
> The expected difference can trigger the need to express this detail > by the usage of two identifiers based on the same metavariable type. I guess that this wording should be clarified a bit more according to the current software development status around the semantic patch language. A

[Cocci] More precise distinction of types for source code searches?

2019-06-24 Thread Markus Elfring
Hello, The semantic patch language supports metavariables. It can occur then that a source code search should be performed for items which should be different while they belong still to the same data type. (If these items would be identical, the software situation would provide opportunities to

Re: [Cocci] Checking redundant variable initialisations with SmPL?

2019-06-23 Thread Markus Elfring
Am 23.06.19 um 15:13 schrieb Julia Lawall: > > > On Sun, 23 Jun 2019, Markus Elfring wrote: > >>> Try >>> >>> ... when any >>> >>> just before the final ). In some circumstaces the parser doesn't accept >>> an expression at the

Re: [Cocci] Checking redundant variable initialisations with SmPL?

2019-06-23 Thread Markus Elfring
> Try > > ... when any > > just before the final ). In some circumstaces the parser doesn't accept > an expression at the end of a sequence like you have here. Thanks for your quick response. The addition of such a SmPL ellipsis helps somehow. But I am still not pleased with the generated

Re: [Cocci] Checking redundant variable initialisations with SmPL?

2019-06-23 Thread Markus Elfring
> Try > > ... when any > > just before the final ). In some circumstaces the parser doesn't accept > an expression at the end of a sequence like you have here. Thanks for your quick response. The addition of such a SmPL ellipsis helps somehow. But I am still not pleased with the generated

Re: [Cocci] Checking redundant variable initialisations with SmPL?

2019-06-23 Thread Markus Elfring
> Yu can do whatever you want, but you will get lotsof false positives if > you keep it. If you really want a star on the declaration then you need > to make two rules. The first that finds the positions of the places that > match and the second that only puts a * when there is both a matched >

Re: [Cocci] Checking redundant variable initialisations with SmPL?

2019-06-23 Thread Markus Elfring
> Yu can do whatever you want, but you will get lotsof false positives if > you keep it. If you really want a star on the declaration then you need > to make two rules. The first that finds the positions of the places that > match and the second that only puts a * when there is both a matched >

Re: [Cocci] Checking redundant variable initialisations with SmPL?

2019-06-23 Thread Markus Elfring
>>> It could be helpful to replace the last line by: >>> >>> ( >>> e3 = <+...var...+> >> >> Can this SmPL specification make sense as another when constraint? > > No. I imagine that a few extensions like the following can become safer. when != do ds while( \( var bo e3 \| var \) );

Re: [Cocci] Checking redundant variable initialisations with SmPL?

2019-06-22 Thread Markus Elfring
>>> In that case, it would also be beneficial to remove the * >> >> I find the asterisk required here > > Yu can do whatever you want, but you will get lotsof false positives if > you keep it. If you really want a star on the declaration I would prefer to use a minus character for the

Re: [Cocci] Checking redundant variable initialisations with SmPL?

2019-06-22 Thread Markus Elfring
> It could be helpful to replace the last line by: > > ( > e3 = <+...var...+> Can this SmPL specification make sense as another when constraint? > | > * var = e3 > ) > > In that case, it would also be beneficial to remove the * I find the asterisk required here > on the variable

Re: [Cocci] Checking redundant variable initialisations with SmPL?

2019-06-22 Thread Markus Elfring
>> elfring@Sonne:~/Projekte/Linux/next-patched> spatch >> ~/Projekte/Coccinelle/janitor/show_questionable_variable_initialisation1.cocci >> drivers/misc/lkdtm/core.c >> … >> exn while in timeout_function >> Fatal error: exception Coccinelle_modules.Common.Impossible(56) >> >> >> How do you think

[Cocci] Checking dependencies for current OCaml compiler version

2019-06-22 Thread Markus Elfring
Hello, I have tried out to build the current Coccinelle software again based on the OPAM switch “4.08.0”. Unfortunately, I stumble on the following error message. … ocamlfind ocamlc -c -no-alias-deps -I . stdcompat__pervasives.ml -o stdcompat__pervasives.cmo File "stdcompat__pervasives.ml",

[Cocci] Moving exception handling code to the end of a function implementation with SmPL?

2019-06-21 Thread Markus Elfring
Hello, I became interested in another source code transformation again. I would like to move a bit of common code to the end of a function implementation with the help of the following script for the semantic patch language. @replacement@ expression info, result; identifier target, work; type

Re: [Cocci] Coccinelle: Add a SmPL script for the reconsideration of redundant dev_err() calls

2019-06-21 Thread Markus Elfring
> I still don't see the point of specifying return. Why not just S, where S > is a statement metavariable? Do you find the following SmPL change specification more appropriate? @deletion depends on patch@ expression e; statement s; @@ e = devm_ioremap_resource(...); if (IS_ERR(e)) ( -{ -

Re: [Cocci] Coccinelle: Add a SmPL script for the reconsideration of redundant dev_err() calls

2019-06-21 Thread Markus Elfring
> I still don't see the point of specifying return. Why not just S, where S > is a statement metavariable? Do you find the following SmPL change specification more appropriate? @deletion depends on patch@ expression e; statement s; @@ e = devm_ioremap_resource(...); if (IS_ERR(e)) ( -{ -

Re: Coccinelle: Add a SmPL script for the reconsideration of redundant dev_err() calls

2019-06-21 Thread Markus Elfring
> I think that something like > > if (IS_ERR(e)) > { > <+... > *dev_err(...) > ...+> > } > > would be more appropriate. Whether there is a return or not doesn't > really matter. Do you find the following SmPL change specification useful and acceptable? @deletion depends on patch@ expression e;

Re: [Cocci] Coccinelle: Add a SmPL script for the reconsideration of redundant dev_err() calls

2019-06-20 Thread Markus Elfring
>> Would you prefer to clarify a more advanced approach? > > I think that something like > > if (IS_ERR(e)) > { > <+... > *dev_err(...) > ...+> > } > > would be more appropriate. This SmPL construct can be more powerful. > Whether there is a return or not doesn't really matter. Such an

Re: Coccinelle: Add a SmPL script for the reconsideration of redundant dev_err() calls

2019-06-20 Thread Markus Elfring
>> +@display depends on context@ >> +expression e; >> +@@ >> + e = devm_ioremap_resource(...); >> + if (IS_ERR(e)) >> + { >> +* dev_err(...); >> +return (...); >> + } > > Why do you assume that there is exactly one dev_err and one return after > the test? I propose to start with the

Re: Coccinelle: Add a SmPL script for the reconsideration of redundant dev_err() calls

2019-06-20 Thread Markus Elfring
>> +@display depends on context@ >> +expression e; >> +@@ >> + e = devm_ioremap_resource(...); >> + if (IS_ERR(e)) >> + { >> +* dev_err(...); >> +return (...); >> + } > > Why do you assume that there is exactly one dev_err and one return after > the test? I propose to start with the

[Cocci] [PATCH] Coccinelle: Add a SmPL script for the reconsideration of redundant dev_err() calls

2019-06-20 Thread Markus Elfring
From: Markus Elfring Date: Thu, 20 Jun 2019 19:12:53 +0200 The function “devm_ioremap_resource” contains appropriate error reporting. Thus it can be questionable to present another error message at other places. Provide design options for the adjustment of affected source code by the means

[Cocci] Checking redundant variable initialisations with SmPL?

2019-06-20 Thread Markus Elfring
Hello, A patch on a topic like “[next] lkdtm: remove redundant initialization of ret” caught also my software development attention. https://lkml.org/lkml/2019/6/14/265 https://lore.kernel.org/patchwork/patch/1088971/ https://lore.kernel.org/lkml/20190614094311.24024-1-colin.k...@canonical.com/

Re: [Cocci] Handling of pointer expressions by SmPL

2019-06-19 Thread Markus Elfring
>> Would you like to add this information to the software documentation? > > Not really. The documentation can't defend against everyone's imagination. Will it become helpful to mention the metavariable type “expression *” also in the SmPL manual?

Re: [Cocci] Handling of pointer expressions by SmPL

2019-06-19 Thread Markus Elfring
>> Would you like to add this information to the software documentation? > > Not really. The documentation can't defend against everyone's imagination. Will it become helpful to mention the metavariable type “expression *” also in the SmPL manual?

Re: [Cocci] Handling of pointer expressions by SmPL

2019-06-19 Thread Markus Elfring
> You can't specify pointer dereferences by metavariables. Thanks for another clarification for a detail by the Coccinelle software. I assumed that this would be useful functionality for the specification “expression *X;”. > The pattern is only in the pattern. It is not partly in the

Re: [Cocci] Handling of pointer expressions by SmPL

2019-06-19 Thread Markus Elfring
>>> Metavariables have types. Here X has pointer type. >> >> Our understanding of this software detail seems to match. >> >> But I assume that the asterisk can be treated in a different way by >> the isomorphism definition language in comparison to the semantic >> patch language. >> How much does

Re: [Cocci] Handling of pointer expressions by SmPL

2019-06-19 Thread Markus Elfring
> How would Coccinelle know that a pointer is expected if there is no asterisk? I am still trying to achieve a better understanding around the interpretation of the specification “expression *X;”.

Re: [Cocci] Checking for a null pointer with SmPL

2019-06-18 Thread Markus Elfring
> How would Coccinelle know that a pointer is expected if there is no asterisk? SmPL expression metavariables can handle also pointer variables from C code, can't they? Type distinctions have got other consequences for isomorphism definitions. Regards, Markus

Re: [Cocci] Checking for a null pointer with SmPL

2019-06-18 Thread Markus Elfring
> Isomorphisms have a cost, so the provided isomorphism only converts !X to > X == NULL when X is a pointer. It seems that the Coccinelle software has got restrictions on the interpretation of pointers so far. Is a pointer recognised for application of isomorphisms by the semantic patch language

Re: drivers: Inline code in devm_platform_ioremap_resource() from two functions

2019-06-18 Thread Markus Elfring
>> Would you like to check the software circumstances once more >> for the generation of a similar code structure by a C compiler >> (or optimiser)? > > As said: unfortunately, I don't have the time to do that I became curious if you would like to adjust your software development attention a bit

Re: [Cocci] Checking for a null pointer with SmPL

2019-06-18 Thread Markus Elfring
> If you turn off isomorphisms, it will only match exactly what you have > written. This setting can occasionally be appropriate. > Isomorphisms have a cost, so the provided isomorphism only converts !X to > X == NULL when X is a pointer. If you want to make an isomorphism that > does

Re: [Cocci] Checking for a null pointer with SmPL

2019-06-18 Thread Markus Elfring
> As I already told you, the isomorphisms are applied before matching > against the C code. At that time, this information is not available. Can the software situation be clarified also by omitting Coccinelle's isomorphisms? (Can this functionality be temporarily switched off for a specific

Re: [Cocci] drivers: Inline code in devm_platform_ioremap_resource() from two functions

2019-06-17 Thread Markus Elfring
>> Two function calls were combined in this function implementation. >> Inline corresponding code so that extra error checks can be avoided here. > > What exactly is the purpose of this ? I suggest to take another look at the need and relevance of involved error checks in the discussed function

Re: [Cocci] Checking for a null pointer with SmPL

2019-06-17 Thread Markus Elfring
>> Example: >> struct setkey_parm *psetkeyparm; > > As I already told you, the isomorphisms are applied before matching > against the C code. At that time, this information is not available. Under which circumstances will the Coccinelle software become able to take available data type

Re: [Cocci] Checking for a null pointer with SmPL

2019-06-17 Thread Markus Elfring
>> Can the mentioned SmPL script variant work also without taking extra >> software transformations by isomorphism specifications into account? > > Well, you already know that it doesn't. So oviously the answe is that it > cannot. At the moment. > If you indicate that the expression ex is a

Re: [Cocci] Checking for a null pointer with SmPL

2019-06-17 Thread Markus Elfring
> Isomorphisms happen in advance, not during the matching process. Can the mentioned SmPL script variant work also without taking extra software transformations by isomorphism specifications into account? Regards, Markus ___ Cocci mailing list

Re: [Cocci] Checking for a null pointer with SmPL

2019-06-17 Thread Markus Elfring
>> Should an isomorphism specification like “not_ptr2” help here? >> https://github.com/coccinelle/coccinelle/blob/19ee1697bf152d37a78a20cefe148775bf4b0e0d/standard.iso#L157 > > No, because Coccinelle does not know that it is a pointer. > How should it know? Can the software determine that the

Re: [Cocci] Checking for a null pointer with SmPL

2019-06-16 Thread Markus Elfring
> In the second case, Coccinelle has no way of knowing that ex is a pointer, Can the software support pointer expressions better? > so it doesn't feel motivated to consider that ex should be compared to NULL. Should an isomorphism specification like “not_ptr2” help here?

[Cocci] Checking for a null pointer with SmPL

2019-06-16 Thread Markus Elfring
Hello, A patch on a topic like “staging/rtl8723bs/core/rtw_ap: Remove redundant call to memset” caught also my software development attention. https://lkml.org/lkml/2019/6/15/220 https://lore.kernel.org/patchwork/patch/1089416/

Re: [Cocci] drivers: Inline code in devm_platform_ioremap_resource() from two functions

2019-06-15 Thread Markus Elfring
>> Two function calls were combined in this function implementation. >> Inline corresponding code so that extra error checks can be avoided here. > > I don't see any point to this at all. Would you like to take another look at corresponding design options? How do you think about to check run

[PATCH] drivers: Inline code in devm_platform_ioremap_resource() from two functions

2019-06-14 Thread Markus Elfring
From: Markus Elfring Date: Fri, 14 Jun 2019 11:05:33 +0200 Two function calls were combined in this function implementation. Inline corresponding code so that extra error checks can be avoided here. Signed-off-by: Markus Elfring --- drivers/base/platform.c | 39

Re: [Cocci] Wider usage of “fresh identifiers”?

2019-06-12 Thread Markus Elfring
> Apparently I'm missing this obscure line in the documentation: > > "Fresh identifier metavariables must only be used in + code." > > Any suggestions on how to work around this, other than use Python? Would you get into the mood to adjust this software situation any more? (Increase OCaml

Re: Coccinelle: api: add devm_platform_ioremap_resource script

2019-06-12 Thread Markus Elfring
>> The flag “IORESOURCE_MEM” is passed as the second parameter for the call >> of the function “platform_get_resource” in this refactoring. > > In that particular case, we maybe should consider separate inline > helpers instead of passing this is a parameter. > > Maybe it would even be more

Re: [Cocci] Working with pipes for parallel SmPL data processing?

2019-06-11 Thread Markus Elfring
Am 10.06.19 um 23:00 schrieb Julia Lawall: > > > On Sun, 9 Jun 2019, Markus Elfring wrote: > >> Hello, >> >> The Coccinelle software supports also a variant of parallel data processing >> after the parameter “--jobs” was passed. >> htt

Re: [Cocci] Improving parallel SmPL data processing for database support

2019-06-10 Thread Markus Elfring
> https://github.com/coccinelle/coccinelle/issues/50 Would you like to adjust the situation around better software collaboration? https://docs.sqlalchemy.org/en/13/core/pooling.html#using-connection-pools-with-multiprocessing Regards, Markus ___ Cocci

[Cocci] Working with pipes for parallel SmPL data processing?

2019-06-09 Thread Markus Elfring
Hello, The Coccinelle software supports also a variant of parallel data processing after the parameter “--jobs” was passed. https://github.com/coccinelle/coccinelle/blob/7ec31ed1fadf738bc487ccefdc63bfe0598f44cc/docs/manual/spatch_options.tex#L745 It is nice when it works to distribute analysis

Re: Coccinelle: api: add devm_platform_ioremap_resource script

2019-06-09 Thread Markus Elfring
>>> +- e1 = devm_ioremap_resource(arg4, id); >>> ++ e1 = devm_platform_ioremap_resource(arg1, arg3); >> >> Can the following specification variant matter for the shown SmPL >> change approach? >> >> + e1 = >> +- devm_ioremap_resource(arg4, id >> ++ devm_platform_ioremap_resource(arg1, arg3

Re: Coccinelle: api: add devm_platform_ioremap_resource script

2019-06-08 Thread Markus Elfring
> +- e1 = devm_ioremap_resource(arg4, id); > ++ e1 = devm_platform_ioremap_resource(arg1, arg3); Can the following specification variant matter for the shown SmPL change approach? + e1 = +- devm_ioremap_resource(arg4, id ++ devm_platform_ioremap_resource(arg1, arg3 +

Re: [Cocci] Handling of designated initialisers by SmPL?

2019-06-08 Thread Markus Elfring
> Would you like to try another SmPL script variant out? @replacement@ constant text; expression value; @@ .driver = { - .name = text, - .of_match_table = value, - }, + .name = text, + .of_match_table = of_match_ptr(value), + }, How do you

Re: [Cocci] How to replace obsolete #ifdef's?

2019-06-07 Thread Markus Elfring
> Just wrapping the assignment into the macro call turned out to be easy. I am curious how your transformation approaches will evolve further. > But I haven't found a way to remove the now #ifdef :( The support for preprocessor functionality is limited by the semantic patch language so far.

Re: [Cocci] How to replace obsolete #ifdef's?

2019-06-07 Thread Markus Elfring
>> Will similar software updates become more challenging for the initially >> described handling of designated initialisers for known data structures? > > This is in the spirit of the solution I already proposed. Would you like to compare transformation results also for the following SmPL change

Re: [Cocci] How to replace obsolete #ifdef's?

2019-06-07 Thread Markus Elfring
>> Will similar software updates become more challenging for the initially >> described handling of designated initialisers for known data structures? > > This is in the spirit of the solution I already proposed. How do you think about the following SmPL transformation approach? @replacement@

Re: [Cocci] How to replace obsolete #ifdef's?

2019-06-07 Thread Markus Elfring
> but not: > > @@ > @@ > > - #ifdef FOO > bar(); > - #endif The deletion of these preprocessor statements is not directly supported in the shown way by the Coccinelle software at the moment. But I got another code transformation idea which would not be so convenient. The semantic patch

[Cocci] Improving parallel SmPL data processing for database support

2019-06-07 Thread Markus Elfring
Hello, I occasionally use the software “SQLAlchemy” for easy storage of source code data. I noticed once more that information was not permanently stored if the parameter “-j 4” was passed to the program “spatch” while the database “PostgreSQL 11.3-7.1” was selected as the desired storage

Re: [Cocci] How to replace obsolete #ifdef's?

2019-06-06 Thread Markus Elfring
> Ifdefs are parsed as comments. I am curious under which circumstances this software situation can be changed for the better support of preprocessor functionality. Regards, Markus ___ Cocci mailing list Cocci@systeme.lip6.fr

Re: [Cocci] How to replace obsolete #ifdef's?

2019-06-06 Thread Markus Elfring
> #ifdefs are comments. I wonder about this wording. I hope that the corresponding software situation can be improved further for complete support of preprocessor functionality. > If you remove a contiguous sequence of things, the comments between them > disappear as well. Such a source code

Re: [Cocci] How to replace obsolete #ifdef's?

2019-06-06 Thread Markus Elfring
> It seems that spatch currently just doesn't understand preprocessor > directives at all, I find this view only partly appropriate. There is preprocessor functionality supported by the semantic patch language. Example:

Re: [Cocci] How to replace obsolete #ifdef's?

2019-06-05 Thread Markus Elfring
> Just wrapping the assignment into the macro call turned out to be easy. This feedback seems to be promising. > But I haven't found a way to remove the now #ifdef :( I get the following test result for a corresponding SmPL transformation approach. @replacement@ identifier value; @@ -#ifdef

Re: Coccinelle: Searching for “when done” in function comments

2019-06-05 Thread Markus Elfring
> Does such a source code analysis approach indicate any details > which should be improved for the affected software documentation? I have constructed another SmPL script variant. It can point out that the text “ when done” occurs in comment lines before 48 function implementations which are

Re: Coccinelle: semantic patch for missing of_node_put

2019-06-04 Thread Markus Elfring
> let add_function f c = > if not (List.mem f !relevant_functions) > then > begin > let s = String.concat " " > ( > (List.map String.lowercase_ascii >(List.filter > (function x -> >Str.string_match >

Re: Coccinelle: semantic patch for missing of_node_put

2019-06-04 Thread Markus Elfring
>> Thus I imagine that an other documentation format would be safer >> and more helpful for the determination of a corresponding API >> system property. > > Our script will remove '* ','\ n','\t' and so on from the comments in the > function header > and then merge them into one line, * Would

Re: Coccinelle: semantic patch for missing of_node_put

2019-06-04 Thread Markus Elfring
> We currently use the following Ocaml script to automatically > collect functions that need to be considered. > > @initialize:ocaml@ > @@ > > let relevant_str = "use of_node_put() on it when done" I suggest to reconsider this search pattern. The mentioned words are distributed over text lines

Re: Coccinelle: semantic patch for missing of_node_put

2019-06-03 Thread Markus Elfring
> 2, A general method. > We also try to get the list of functions to consider by writing a SmPL, > but this method is not feasible at present, because it is not easy to parse > the comment > header information of these functions. The situation was improved once more also for the Coccinelle

Re: [Cocci] Setting the match result by SmPL script rule

2019-06-03 Thread Markus Elfring
>> How do you think about to filter any text by regular expressions >> for semantic patch language constraints? > > Not supported. This software limitation and current development status has got consequences as usual. * It would be nice if comment contents could be directly restricted also by

[Cocci] Object-orientation for metavariables

2019-06-02 Thread Markus Elfring
Hello, The metavariables of the semantic patch variables provide a programming interface for various information from source code. They were designed in the way so far that a single primary content is handled. The contents can refer also to more detailed data structures then. The system default

Re: [Cocci] accessing comments

2019-06-02 Thread Markus Elfring
> It is now possible to match the comments before, within, and after the > match of a token, via a comments metavariable. Would anybody become interested to discuss corresponding software development challenges and fine-tuning possibilities any more since the support for the Python programming

Re: [Cocci] Data exchange over network interfaces by SmPL scripts

2019-06-01 Thread Markus Elfring
> Unfortunately, I observed during a few runs on my test system > that the displayed record sets can vary. Thus I guess that this approach > (which works together with Python multi-threading functionality) will need > further software adjustments. I stumbled on general software development

Re: [Cocci] Controlling where braces are located?

2019-05-29 Thread Markus Elfring
> … But it would be nice if I could control some commonly-used options, … Thanks for your feedback. > I don't have anything to contribute other than "I need this feature". Will any programmers appear who would be willing to contribute more significant development resources? Regards, Markus

Re: [Cocci] Controlling where braces are located?

2019-05-29 Thread Markus Elfring
> I have this rule, but spatch puts the left brace on the same line as > if-statement: … > How can I fix this? There are some software development options available. * Do you expect that the Coccinelle software should pick a coding style up from the mentioned source files automatically? * I

Re: [Cocci] Checking change scope for a data type replacement

2019-05-27 Thread Markus Elfring
>> @replacement3@ >> identifier x; >> @@ >> -int >> +int* >> x; >> <+... >> -f >> +g >> (x); >> ...+> > > His example shows that he wants to change a parameter type, He would like to call a function which gets a single pointer passed instead of an integer by possibly varying variables. >

Re: [Cocci] "depends on" per file

2019-05-27 Thread Markus Elfring
> The issue is that if the rule gets matched in one file, > it will include the header in every other file as well, How did you choose the selected source file combination? > because the "depends on ever" clause is satisfied. > Is there a way to tell coccinelle "apply this rule to file X, > but

Re: [Cocci] Checking change scope for a data type replacement

2019-05-27 Thread Markus Elfring
> In other words, in my original code "int x" is passed to "void f(int)" as a > paramter, > and I would like to apply the following transformations: How do you think about to try a SmPL change specification out like the following? @replacement3@ identifier x; @@ -int +int* x; <+... -f +g

Re: [Cocci] Checking change scope for a data type replacement

2019-05-27 Thread Markus Elfring
>> @replacement@ >> identifier x; >> @@ >> -int >> +int* >>   x; > >> >> In which scopes would you like to add the asterisk for the usage of a pointer >> data type? … > 1) "x" has a type of "int *" The asterisk addition seems to work for (local) variables. > 2) the new "int *x" gets passed to a

Re: [Cocci] Checking change scope for a data type replacement

2019-05-27 Thread Markus Elfring
> Am I missing something? It depends on details. Your initial transformation approach can be written also as follows. @replacement@ identifier x; @@ -int +int* x; In which scopes would you like to add the asterisk for the usage of a pointer data type? Do you expect that function parameters

Re: [Cocci] Checking structures for usage of OCaml variables with inherited SmPL data

2019-05-27 Thread Markus Elfring
> Besides comments, everything is either a string or a position, > ie type pos list, where the type pos is found in man Coccilib. How do you think about to improve the programming interface descriptions here? Which data structures would be relevant for the metavariable “identifier”? Do they

[Cocci] Checking structures for usage of OCaml variables with inherited SmPL data

2019-05-27 Thread Markus Elfring
Hello, The semantic patch language supports also the specification and handling of OCaml script rules. Inherited SmPL variables can be connected to corresponding local variable names. I would appreciate if the determination of the provided data structures can become easier. * Which data types

Re: [Cocci] accessing comments

2019-05-27 Thread Markus Elfring
> The before, within and after comments are lists of strings. I got further software development ideas around the provided data structures. * If you would like to search within the text of multi-line comments by the means of regular expressions, the list elements need to be concatenated

Re: [Cocci] accessing comments

2019-05-26 Thread Markus Elfring
> The when any's allow any possible match.  There are three calls to foo so > three possible matches. Can my software interpretation of unexpected code repetition be adjusted also by moving the code “\(foo@c3();\@c4\)” into another SmPL rule? Can it make sense to split the OCaml script rule then

Re: [Cocci] accessing comments

2019-05-26 Thread Markus Elfring
> The when any's allow any possible match. I agree to this technical aspect. > There are three calls to foo so three possible matches. I find that this possibility does not require to repeat the evaluation for the complete OCaml script rule. I would find a possible repetition eventually

Re: [Cocci] accessing comments

2019-05-26 Thread Markus Elfring
>> * How do you think about my expectation that the OCaml script rule >>   should be evaluated only once because a single function implementation >>   example is analysed here? > > The multiple times have to do with the ... not the comment variables. I do not expect so far that the SmPL code “...

Re: [Cocci] accessing comments

2019-05-26 Thread Markus Elfring
>> elfring@Sonne:~/Projekte/Coccinelle/20160205> COCCINELLE_HOME=$(pwd) >> /usr/local/bin/opam config exec --switch 4.07.1 ./spatch.opt >> demos/comments.cocci demos/comments.c >> … >> c1b: /* before the function … */ >> … >> >> >> * Now I wonder why this display is presented in three

Re: [Cocci] accessing comments

2019-05-26 Thread Markus Elfring
>> Can it be that such a comment would belong to the function call operator >> (open or closing parenthesis) instead of the identifier “foo”? > > You put the comment metavariable on whatever you want. This functionality is generally nice. > The report for the comment in the argument list comes

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