summaryrefslogtreecommitdiff
path: root/tools/lib/subcmd/help.c
diff options
context:
space:
mode:
authorGeorgi Djakov <djakov@kernel.org>2023-08-22 00:59:05 +0300
committerGeorgi Djakov <djakov@kernel.org>2023-08-22 01:00:45 +0300
commita3dd14c0d079c214c4de7939dfbb8738887e67e7 (patch)
tree39925464504ee4fcf4b294cebe9ec06b3dadfd11 /tools/lib/subcmd/help.c
parent10cb3abb99939f6a81b714a64915b1468597fb74 (diff)
parent2ccdd1b13c591d306f0401d98dedc4bdcd02b421 (diff)
Merge tag 'v6.5-rc6' into icc-next
The fixes that got merged into v6.5-rc6 are needed here. Signed-off-by: Georgi Djakov <djakov@kernel.org>
Diffstat (limited to 'tools/lib/subcmd/help.c')
-rw-r--r--tools/lib/subcmd/help.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/tools/lib/subcmd/help.c b/tools/lib/subcmd/help.c
index 67a8d6b740ea..adfbae27dc36 100644
--- a/tools/lib/subcmd/help.c
+++ b/tools/lib/subcmd/help.c
@@ -68,8 +68,13 @@ void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes)
while (ci < cmds->cnt && ei < excludes->cnt) {
cmp = strcmp(cmds->names[ci]->name, excludes->names[ei]->name);
if (cmp < 0) {
- zfree(&cmds->names[cj]);
- cmds->names[cj++] = cmds->names[ci++];
+ if (ci == cj) {
+ ci++;
+ cj++;
+ } else {
+ zfree(&cmds->names[cj]);
+ cmds->names[cj++] = cmds->names[ci++];
+ }
} else if (cmp == 0) {
ci++;
ei++;
@@ -77,10 +82,11 @@ void exclude_cmds(struct cmdnames *cmds, struct cmdnames *excludes)
ei++;
}
}
-
- while (ci < cmds->cnt) {
- zfree(&cmds->names[cj]);
- cmds->names[cj++] = cmds->names[ci++];
+ if (ci != cj) {
+ while (ci < cmds->cnt) {
+ zfree(&cmds->names[cj]);
+ cmds->names[cj++] = cmds->names[ci++];
+ }
}
for (ci = cj; ci < cmds->cnt; ci++)
zfree(&cmds->names[ci]);