From: Keith Busch Date: Mon, 1 Aug 2016 21:25:38 +0000 (-0600) Subject: Use different error code when command not found X-Git-Tag: v0.9~19 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=f0af752942fb3613f643164663bb7ce60148d1b0;p=users%2Fhch%2Fnvme-cli.git Use different error code when command not found A failed system call returns -1 with errno set, so lets differentiate a failed system call from not finding a command at all. This suppresses large help messages on any generic system call failure. Signed-off-by: Keith Busch --- diff --git a/nvme.c b/nvme.c index 3e1b3d6..a33bc0d 100644 --- a/nvme.c +++ b/nvme.c @@ -2624,7 +2624,7 @@ int main(int argc, char **argv) setlocale(LC_ALL, ""); ret = handle_plugin(argc - 1, &argv[1], nvme.extensions); - if (ret == -1) + if (ret == -ENOTTY) general_help(&builtin); return ret; diff --git a/plugin.c b/plugin.c index dd971bf..ba771f9 100644 --- a/plugin.c +++ b/plugin.c @@ -143,7 +143,7 @@ int handle_plugin(int argc, char **argv, struct plugin *plugin) /* Check extensions only if this is running the built-in plugin */ if (plugin->name) { printf("ERROR: Invalid sub-command '%s' for plugin %s\n", str, plugin->name); - return -1; + return -ENOTTY; } extension = plugin->next; @@ -162,5 +162,5 @@ int handle_plugin(int argc, char **argv, struct plugin *plugin) extension = extension->next; } printf("ERROR: Invalid sub-command '%s'\n", str); - return -1; + return -ENOTTY; }