ctdb-tools: Avoid deferencing argv[0] if argc == 0
authorAmitay Isaacs <amitay@gmail.com>
Tue, 7 Mar 2017 03:13:10 +0000 (14:13 +1100)
committerMartin Schwenke <martins@samba.org>
Wed, 29 Mar 2017 09:07:18 +0000 (11:07 +0200)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12723

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
Autobuild-User(master): Martin Schwenke <martins@samba.org>
Autobuild-Date(master): Wed Mar 29 11:07:18 CEST 2017 on sn-devel-144

ctdb/tools/ctdb_event.c

index 62b4b91..8e2dca7 100644 (file)
@@ -223,23 +223,26 @@ static int command_status(TALLOC_CTX *mem_ctx, struct tool_context *tctx,
        talloc_free(req);
        if (! status) {
                fprintf(stderr, "Failed to get event %s status, ret=%d\n",
-                       argv[0], ret);
+                       ctdb_event_to_string(event), ret);
                return ret;
        }
 
        if (result != 0) {
                fprintf(stderr, "Failed to get event %s status, result=%d\n",
-                       argv[0], result);
+                       ctdb_event_to_string(event), result);
                return result;
        }
 
        if (script_list == NULL) {
                if (state == CTDB_EVENT_LAST_RUN) {
-                       printf("Event %s has never run\n", argv[0]);
+                       printf("Event %s has never run\n",
+                              ctdb_event_to_string(event));
                } else if (state == CTDB_EVENT_LAST_PASS) {
-                       printf("Event %s has never passed\n", argv[0]);
+                       printf("Event %s has never passed\n",
+                               ctdb_event_to_string(event));
                } else if (state == CTDB_EVENT_LAST_FAIL) {
-                       printf("Event %s has never failed\n", argv[0]);
+                       printf("Event %s has never failed\n",
+                               ctdb_event_to_string(event));
                }
        } else {
                for (i=0; i<script_list->num_scripts; i++) {