summaryrefslogtreecommitdiff
path: root/dev-util/perf/files/perf-6.18-subcmd.patch
blob: e3e067efdd077c3a87f08912cf55c3c01abd0529 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Fix for --help command when no commands are excluded.

Link: https://lore.kernel.org/lkml/20251202213632.2873731-1-sjayaram@akamai.com/

See also: https://lore.kernel.org/lkml/aTXQw9dtP5df7LmP@gentoo.org/

--- a/tools/lib/subcmd/help.c
+++ b/tools/lib/subcmd/help.c
@@ -97,11 +97,13 @@ void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes)
 			ei++;
 		}
 	}
-	if (ci != cj) {
-		while (ci < cmds->cnt) {
-			cmds->names[cj++] = cmds->names[ci];
-			cmds->names[ci++] = NULL;
+	while (ci < cmds->cnt) {
+		if (ci != cj) {
+			cmds->names[cj] = cmds->names[ci];
+			cmds->names[ci] = NULL;
 		}
+		ci++;
+		cj++;
 	}
 	for (ci = cj; ci < cmds->cnt; ci++)
 		assert(cmds->names[ci] == NULL);
--