Thread (80 messages) 80 messages, 20 authors, 2021-02-16

Re: [PATCH 29/29] tools: Avoid comma separated statements

From: Thomas Renninger <trenn@suse.com>
Date: 2020-08-26 09:30:20
Also in: linux-kselftest, linux-pm

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:
quoted hunk ↗ jump to hunk
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

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help