summaryrefslogtreecommitdiff
path: root/help.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2016-09-29 15:27:31 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-09-29 22:42:18 (GMT)
commit9ed0d8d6e6de7737fe9a658446318b86e57c6fad (patch)
tree82fdefc7bd543c99091f5b634947360f75100deb /help.c
parentdbc540c7a5827529a3f58befc9e5b81a31ec8fab (diff)
downloadgit-9ed0d8d6e6de7737fe9a658446318b86e57c6fad.zip
git-9ed0d8d6e6de7737fe9a658446318b86e57c6fad.tar.gz
git-9ed0d8d6e6de7737fe9a658446318b86e57c6fad.tar.bz2
use QSORT
Apply the semantic patch contrib/coccinelle/qsort.cocci to the code base, replacing calls of qsort(3) with QSORT. The resulting code is shorter and supports empty arrays with NULL pointers. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'help.c')
-rw-r--r--help.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/help.c b/help.c
index 2ff3b5a..53e2a67 100644
--- a/help.c
+++ b/help.c
@@ -170,8 +170,7 @@ void load_command_list(const char *prefix,
if (exec_path) {
list_commands_in_dir(main_cmds, exec_path, prefix);
- qsort(main_cmds->names, main_cmds->cnt,
- sizeof(*main_cmds->names), cmdname_compare);
+ QSORT(main_cmds->names, main_cmds->cnt, cmdname_compare);
uniq(main_cmds);
}
@@ -190,8 +189,7 @@ void load_command_list(const char *prefix,
}
free(paths);
- qsort(other_cmds->names, other_cmds->cnt,
- sizeof(*other_cmds->names), cmdname_compare);
+ QSORT(other_cmds->names, other_cmds->cnt, cmdname_compare);
uniq(other_cmds);
}
exclude_cmds(other_cmds, main_cmds);
@@ -238,8 +236,7 @@ void list_common_cmds_help(void)
longest = strlen(common_cmds[i].name);
}
- qsort(common_cmds, ARRAY_SIZE(common_cmds),
- sizeof(common_cmds[0]), cmd_group_cmp);
+ QSORT(common_cmds, ARRAY_SIZE(common_cmds), cmd_group_cmp);
puts(_("These are common Git commands used in various situations:"));
@@ -324,8 +321,7 @@ const char *help_unknown_cmd(const char *cmd)
add_cmd_list(&main_cmds, &aliases);
add_cmd_list(&main_cmds, &other_cmds);
- qsort(main_cmds.names, main_cmds.cnt,
- sizeof(*main_cmds.names), cmdname_compare);
+ QSORT(main_cmds.names, main_cmds.cnt, cmdname_compare);
uniq(&main_cmds);
/* This abuses cmdname->len for levenshtein distance */
@@ -359,8 +355,7 @@ const char *help_unknown_cmd(const char *cmd)
levenshtein(cmd, candidate, 0, 2, 1, 3) + 1;
}
- qsort(main_cmds.names, main_cmds.cnt,
- sizeof(*main_cmds.names), levenshtein_compare);
+ QSORT(main_cmds.names, main_cmds.cnt, levenshtein_compare);
if (!main_cmds.cnt)
die(_("Uh oh. Your system reports no Git commands at all."));