aboutsummaryrefslogtreecommitdiff
path: root/qemu-io-cmds.c
diff options
context:
space:
mode:
authorDr. David Alan Gilbert <dgilbert@redhat.com>2020-08-24 11:29:14 +0100
committerKevin Wolf <kwolf@redhat.com>2020-10-02 15:46:40 +0200
commitda16f4b867e494b0a73ec74555804209c819d2f8 (patch)
treef87253ba6dec2e116c5b3e0840948c9ccc881633 /qemu-io-cmds.c
parent8e7b122bf85e114c1e94443f82244675bbe3d1f3 (diff)
downloadqemu-da16f4b867e494b0a73ec74555804209c819d2f8.zip
qemu-da16f4b867e494b0a73ec74555804209c819d2f8.tar.gz
qemu-da16f4b867e494b0a73ec74555804209c819d2f8.tar.bz2
qemu-io-cmds: Simplify help_oneline
help_oneline is declared and starts as: static void help_oneline(const char *cmd, const cmdinfo_t *ct) { if (cmd) { printf("%s ", cmd); } else { printf("%s ", ct->name); if (ct->altname) { printf("(or %s) ", ct->altname); } } However, there are only two routes to help_oneline being called: help_f -> help_all -> help_oneline(ct->name, ct) help_f -> help_onecmd(argv[1], ct) In the first case, 'cmd' and 'ct->name' are the same thing, so it's impossible for the if (cmd) to be false and then validly print ct->name - this is upsetting gcc ( https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96739 ) In the second case, cmd is argv[1] and we know we've got argv[1] so again (cmd) is non-NULL. Simplify help_oneline by just printing cmd. (Also strengthen argc check just to be pedantic) Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Message-Id: <20200824102914.105619-1-dgilbert@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'qemu-io-cmds.c')
-rw-r--r--qemu-io-cmds.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
index baeae86..4153f1c 100644
--- a/qemu-io-cmds.c
+++ b/qemu-io-cmds.c
@@ -2383,14 +2383,7 @@ static const cmdinfo_t sleep_cmd = {
static void help_oneline(const char *cmd, const cmdinfo_t *ct)
{
- if (cmd) {
- printf("%s ", cmd);
- } else {
- printf("%s ", ct->name);
- if (ct->altname) {
- printf("(or %s) ", ct->altname);
- }
- }
+ printf("%s ", cmd);
if (ct->args) {
printf("%s ", ct->args);
@@ -2420,7 +2413,7 @@ static int help_f(BlockBackend *blk, int argc, char **argv)
{
const cmdinfo_t *ct;
- if (argc == 1) {
+ if (argc < 2) {
help_all();
return 0;
}