2019-05-13 09:15:32

by Markus Elfring

[permalink] [raw]
Subject: [PATCH 1/5] Coccinelle: put_device: Adjust a message construction

From: Markus Elfring <[email protected]>
Date: Tue, 7 May 2019 11:20:48 +0200

The Linux coding style tolerates long string literals so that
the provided information can be easier found also by search tools
like grep.
Thus simplify a message construction in a SmPL rule by concatenating text
with two plus operators less.

Signed-off-by: Markus Elfring <[email protected]>
---
scripts/coccinelle/free/put_device.cocci | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/scripts/coccinelle/free/put_device.cocci b/scripts/coccinelle/free/put_device.cocci
index c9f071b0a0ab..3ebebc064f10 100644
--- a/scripts/coccinelle/free/put_device.cocci
+++ b/scripts/coccinelle/free/put_device.cocci
@@ -42,11 +42,10 @@ p1 << search.p1;
p2 << search.p2;
@@

-coccilib.report.print_report(p2[0], "ERROR: missing put_device; "
- + "call of_find_device_by_node on line "
- + p1[0].line
- + ", but without a corresponding object release "
- + "within this function.")
+coccilib.report.print_report(p2[0],
+ "ERROR: missing put_device; call of_find_device_by_node on line "
+ + p1[0].line
+ + ", but without a corresponding object release within this function.")

@script:python depends on org@
p1 << search.p1;
--
2.21.0


2019-05-13 10:22:34

by Julia Lawall

[permalink] [raw]
Subject: Re: [PATCH 1/5] Coccinelle: put_device: Adjust a message construction



On Mon, 13 May 2019, Markus Elfring wrote:

> From: Markus Elfring <[email protected]>
> Date: Tue, 7 May 2019 11:20:48 +0200
>
> The Linux coding style tolerates long string literals so that
> the provided information can be easier found also by search tools
> like grep.
> Thus simplify a message construction in a SmPL rule by concatenating text
> with two plus operators less.

I don't know python very well. Is there any way to unindent, so that the
string doesn't exceed 80 characters, or at least no so much?

On the other hand, I would have much preferred the original msg = code. I
don't understand why it is so offensive.

julia

>
> Signed-off-by: Markus Elfring <[email protected]>
> ---
> scripts/coccinelle/free/put_device.cocci | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/scripts/coccinelle/free/put_device.cocci b/scripts/coccinelle/free/put_device.cocci
> index c9f071b0a0ab..3ebebc064f10 100644
> --- a/scripts/coccinelle/free/put_device.cocci
> +++ b/scripts/coccinelle/free/put_device.cocci
> @@ -42,11 +42,10 @@ p1 << search.p1;
> p2 << search.p2;
> @@
>
> -coccilib.report.print_report(p2[0], "ERROR: missing put_device; "
> - + "call of_find_device_by_node on line "
> - + p1[0].line
> - + ", but without a corresponding object release "
> - + "within this function.")
> +coccilib.report.print_report(p2[0],
> + "ERROR: missing put_device; call of_find_device_by_node on line "
> + + p1[0].line
> + + ", but without a corresponding object release within this function.")
>
> @script:python depends on org@
> p1 << search.p1;
> --
> 2.21.0
>
>

2019-05-13 12:37:43

by Markus Elfring

[permalink] [raw]
Subject: Re: [1/5] Coccinelle: put_device: Adjust a message construction

>> Thus simplify a message construction in a SmPL rule by concatenating text
>> with two plus operators less.
>
> Is there any way to unindent, so that the string doesn't exceed 80 characters,
> or at least no so much?

How does your concern fit to the string literal tolerance from
the Linux coding style?


> On the other hand, I would have much preferred the original msg = code.
> I don't understand why it is so offensive.

I suggested again to avoid the use of extra variables in such cases
(also in the discussed bit of Python source code within a SmPL script).

Regards,
Markus

2019-05-13 13:30:46

by Julia Lawall

[permalink] [raw]
Subject: Re: [1/5] Coccinelle: put_device: Adjust a message construction



On Mon, 13 May 2019, Markus Elfring wrote:

> >> Thus simplify a message construction in a SmPL rule by concatenating text
> >> with two plus operators less.
> >
> > Is there any way to unindent, so that the string doesn't exceed 80 characters,
> > or at least no so much?
>
> How does your concern fit to the string literal tolerance from
> the Linux coding style?

The point of view of the Linux kernel is that if there is no nicer way to
persent the string, exceeding 80 characters is preferable to breaking the
string. But here, at least if Python was not indentation sensitive, there
are much nicer ways to present the string and not exceed 80 characters.

> > On the other hand, I would have much preferred the original msg = code.
> > I don't understand why it is so offensive.
>
> I suggested again to avoid the use of extra variables in such cases
> (also in the discussed bit of Python source code within a SmPL script).

I realize that you don't like it, although I have no idea why. Does it
make the code slower? Less reliable? Less readable? I doubt any of those
things. I think that staying within 80 characters would be a much greater
benefit that all of these baseless concerns.

julia

>
> Regards,
> Markus
>

2019-05-13 13:49:43

by Markus Elfring

[permalink] [raw]
Subject: Re: [1/5] Coccinelle: put_device: Adjust a message construction

> I realize that you don't like it, although I have no idea why.
> Does it make the code slower?

Would you like to compare the run time characteristics from creating and
looking up an identifier for a Python variable to direct passing of
a concatenated string for the desired function call?


> I think that staying within 80 characters would be a much greater
> benefit that all of these baseless concerns.

Are you aware of another code formatting option?
https://docs.python.org/3/reference/lexical_analysis.html#string-literal-concatenation

Regards,
Markus

2019-07-06 13:14:44

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [Cocci] [PATCH 1/5] Coccinelle: put_device: Adjust a message construction

On Mon, May 13, 2019 at 5:59 PM Markus Elfring <[email protected]> wrote:
>
> From: Markus Elfring <[email protected]>
> Date: Tue, 7 May 2019 11:20:48 +0200
>
> The Linux coding style tolerates long string literals so that
> the provided information can be easier found also by search tools
> like grep.
> Thus simplify a message construction in a SmPL rule by concatenating text
> with two plus operators less.
>
> Signed-off-by: Markus Elfring <[email protected]>
> ---

Applied to linux-kbuild.


> scripts/coccinelle/free/put_device.cocci | 9 ++++-----
> 1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/scripts/coccinelle/free/put_device.cocci b/scripts/coccinelle/free/put_device.cocci
> index c9f071b0a0ab..3ebebc064f10 100644
> --- a/scripts/coccinelle/free/put_device.cocci
> +++ b/scripts/coccinelle/free/put_device.cocci
> @@ -42,11 +42,10 @@ p1 << search.p1;
> p2 << search.p2;
> @@
>
> -coccilib.report.print_report(p2[0], "ERROR: missing put_device; "
> - + "call of_find_device_by_node on line "
> - + p1[0].line
> - + ", but without a corresponding object release "
> - + "within this function.")
> +coccilib.report.print_report(p2[0],
> + "ERROR: missing put_device; call of_find_device_by_node on line "
> + + p1[0].line
> + + ", but without a corresponding object release within this function.")
>
> @script:python depends on org@
> p1 << search.p1;
> --
> 2.21.0
>
> _______________________________________________
> Cocci mailing list
> [email protected]
> https://systeme.lip6.fr/mailman/listinfo/cocci



--
Best Regards
Masahiro Yamada