Remove generic error reporting from the lttng client
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 8 Aug 2018 21:48:24 +0000 (17:48 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 16 Aug 2018 20:01:30 +0000 (16:01 -0400)
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 <jeremie.galarneau@efficios.com>
src/bin/lttng/lttng.c

index 08eea54a63200f953ce6e0046d80ababc324e8c9..8842a03b51e0dd1a602b716c40eb2494d8b77836 100644 (file)
@@ -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;
This page took 0.02761 seconds and 5 git commands to generate.