]> git.proxmox.com Git - mirror_corosync.git/commitdiff
cfgtool: Return error when -i doesn't match
authorliangxin1300 <XLiang@suse.com>
Mon, 17 Aug 2020 06:25:47 +0000 (14:25 +0800)
committerJan Friesse <jfriesse@redhat.com>
Tue, 18 Aug 2020 16:15:48 +0000 (18:15 +0200)
Give error message and EXIT_FAILURE return code when -i
option doesn't match.

Signed-off-by: liangxin1300 <XLiang@suse.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
tools/corosync-cfgtool.c

index 48a35a7032b6e0b3c6f7a5b382e123dfd460c81e..3fbe36538a54fb5054726d27646e6390d5517119 100644 (file)
@@ -110,6 +110,7 @@ linkstatusget_do (char *interface_name, int brief)
        char stat_ch;
        char *str;
        totem_transport_t transport_number = TOTEM_TRANSPORT_KNET;
+       int no_match = 1;
 
        printf ("Printing link status.\n");
        result = corosync_cfg_initialize (&handle, NULL);
@@ -201,6 +202,7 @@ linkstatusget_do (char *interface_name, int brief)
                        }
 
                        if (show_current_iface) {
+                               no_match = 0;
                                printf ("LINK ID %s\n", interface_names[i]);
                                printf ("\taddr\t= %s\n", cur_iface_name_space + 1);
                                /*
@@ -270,6 +272,12 @@ linkstatusget_do (char *interface_name, int brief)
                        }
                }
 
+               /* No match for value of -i option */
+               if (no_match) {
+                       rc = EXIT_FAILURE;
+                       fprintf(stderr, "Can't match any IP address or link id\n");
+               }
+
                for (i = 0; i < interface_count; i++) {
                        free(interface_status[i]);
                        free(interface_names[i]);