linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Renninger <trenn@suse.com>
To: Jiri Kosina <trivial@kernel.org>,
	linux-kernel@vger.kernel.org, Joe Perches <joe@perches.com>
Cc: Shuah Khan <shuah@kernel.org>,
	linux-pm@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH 29/29] tools: Avoid comma separated statements
Date: Wed, 26 Aug 2020 11:30:14 +0200	[thread overview]
Message-ID: <6011591.XMClsHuqKX@c100> (raw)
In-Reply-To: <52b68acfeb441b483de188f7e100600291f8c3ec.1598331149.git.joe@perches.com>

Hi,

getting rid of lines with multiple instructions, separated by comma is
certainly a good idea.
One nit pick, though:

Am Dienstag, 25. August 2020, 06:56:26 CEST schrieb Joe Perches:
> Use semicolons and braces.
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  tools/lib/subcmd/help.c                    |  10 +-
>  tools/power/cpupower/utils/cpufreq-set.c   |  14 +-
>  tools/testing/selftests/vm/gup_benchmark.c |  18 +-
>  tools/testing/selftests/vm/userfaultfd.c   | 296 +++++++++++++--------
>  4 files changed, 210 insertions(+), 128 deletions(-)
> 
> diff --git a/tools/lib/subcmd/help.c b/tools/lib/subcmd/help.c
> index 2859f107abc8..bf02d62a3b2b 100644
> --- a/tools/lib/subcmd/help.c
> +++ b/tools/lib/subcmd/help.c
> @@ -65,12 +65,14 @@ void exclude_cmds(struct cmdnames *cmds, struct cmdnames
> *excludes) ci = cj = ei = 0;
>  	while (ci < cmds->cnt && ei < excludes->cnt) {
>  		cmp = strcmp(cmds->names[ci]->name, excludes->names[ei]->name);
> -		if (cmp < 0)
> +		if (cmp < 0) {
>  			cmds->names[cj++] = cmds->names[ci++];
> -		else if (cmp == 0)
> -			ci++, ei++;
> -		else if (cmp > 0)
> +		} else if (cmp == 0) {
> +			ci++;
>  			ei++;
> +		} else if (cmp > 0) {
> +			ei++;
> +		}
>  	}

I can remember patches being rejected with one line statements in a condition,
surounded by braces.
I just read up Documentation/process/coding-style.rst, to be sure this still is up-to-date.
It's not a must, but line 180 says:
"Do not unnecessarily use braces where a single statement will do."

So if this is about coding style cleanup, IMO you should remove braces from single line
statements.

I haven't reviewed every line, but I expect you only split up comma separated instructions
into separate lines and added braces?

Afaik there isn't a specific tag, but having:
cleanup only: No functional change

in the changelog would be nice for people looking for fixes to backport.


Otherwise, I think this is a worthful cleanup.

     Thomas



  reply	other threads:[~2020-08-26  9:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-25  4:55 [PATCH 00/29] treewide: Convert comma separated statements Joe Perches
2020-08-25  4:56 ` [PATCH 29/29] tools: Avoid " Joe Perches
2020-08-26  9:30   ` Thomas Renninger [this message]
2020-08-26 14:45     ` Joe Perches
2020-08-26 16:13       ` Thomas Renninger
2020-09-09  2:09 ` [PATCH 00/29] treewide: Convert " Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6011591.XMClsHuqKX@c100 \
    --to=trenn@suse.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=shuah@kernel.org \
    --cc=trivial@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).