From: Jérémie Galarneau Date: Wed, 8 Aug 2018 21:48:24 +0000 (-0400) Subject: Remove generic error reporting from the lttng client X-Git-Tag: v2.11.0-rc1~155 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=6047170fdd6ff755d4ebe0f4a598e9d1caf24960;p=lttng-tools.git Remove generic error reporting from the lttng client Unsuccessful command results are reported by the lttng client which often results in strange error messages of the form: Error: Could not rotate ... Error: Command error Considering that most commands correctly report their errors, it is safe to remove those generic error reports. Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng/lttng.c b/src/bin/lttng/lttng.c index 08eea54a6..8842a03b5 100644 --- a/src/bin/lttng/lttng.c +++ b/src/bin/lttng/lttng.c @@ -253,6 +253,23 @@ end: return ret; } +static bool command_exists(const char *command) +{ + const struct cmd_struct *cmd = commands; + bool exists = false; + + while (cmd->name != NULL) { + if (!strcmp(command, cmd->name)) { + exists = true; + goto end; + } + cmd++; + } + +end: + return exists; +} + static void show_basic_help(void) { puts("Usage: lttng [--group=GROUP] [--mi=TYPE] [--no-sessiond | --sessiond-path=PATH]"); @@ -403,19 +420,19 @@ static int parse_args(int argc, char **argv) ret = handle_command(argc - optind, argv + optind); switch (ret) { case CMD_WARNING: - WARN("Some command(s) went wrong"); - break; case CMD_ERROR: - ERR("Command error"); break; case CMD_UNDEFINED: - ERR("Undefined command or invalid arguments"); + if (!command_exists(*(argv + optind))) { + MSG("lttng: %s is not an lttng command. See 'lttng --help'.", + *(argv + optind)); + } else { + ERR("Unrecognized argument used with \'%s\' command", + *(argv + optind)); + } break; case CMD_FATAL: - ERR("Fatal error"); - break; case CMD_UNSUPPORTED: - ERR("Unsupported command"); break; case -1: ret = 1;