]> git.proxmox.com Git - mirror_kronosnet.git/commitdiff
[nozzle] fix a few coverity errors in the test suite
authorFabio M. Di Nitto <fdinitto@redhat.com>
Thu, 25 Jul 2019 07:24:26 +0000 (09:24 +0200)
committerFabio M. Di Nitto <fdinitto@redhat.com>
Thu, 25 Jul 2019 08:27:57 +0000 (10:27 +0200)
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
libnozzle/tests/api_nozzle_get_name_by_handle.c
libnozzle/tests/api_nozzle_set_mac.c

index 0fe9eb4fb6297d69c95799665a76003bd2ad4646..c05e44862a69b7684329e530589d3d5d0c4a5b85 100644 (file)
@@ -33,8 +33,12 @@ static int test(void)
        }
 
        device_name_tmp = nozzle_get_name_by_handle(nozzle);
-       if ((!device_name_tmp) && (errno != ENOENT)) {
-               printf("Unable to get name by handle\n");
+       if (!device_name_tmp) {
+               if (errno != ENOENT) {
+                       printf("Unable to get name by handle\n");
+               } else {
+                       printf("received incorrect errno!\n");
+               }
                err = -1;
                goto out_clean;
        }
index 244e866faf0ac49cbff42c59da203773251b43f7..abb96364856a06cb80067a4b5cd0029f6371fefc 100644 (file)
@@ -34,7 +34,7 @@ static int test(void)
        size_t size = IFNAMSIZ;
        int err=0;
        nozzle_t nozzle;
-       char *original_mac = NULL, *current_mac = NULL, *temp_mac = NULL, *err_mac = NULL;
+       char *original_mac = NULL, *current_mac = NULL, *temp_mac = NULL;
        struct ether_addr *orig_mac, *cur_mac, *tmp_mac;
 
        printf("Testing set MAC\n");
@@ -96,8 +96,10 @@ static int test(void)
                goto out_clean;
        }
 
-       if (current_mac)
+       if (current_mac) {
                free(current_mac);
+               current_mac = NULL;
+       }
 
        if (nozzle_get_mac(nozzle, &current_mac) < 0) {
                printf("Unable to get current MAC address.\n");
@@ -124,19 +126,13 @@ static int test(void)
 
        printf("Pass NULL to set_mac (pass2)\n");
        errno = 0;
-       if ((nozzle_set_mac(NULL, err_mac) >= 0) || (errno != EINVAL)) {
+       if ((nozzle_set_mac(NULL, current_mac) >= 0) || (errno != EINVAL)) {
                printf("Something is wrong in nozzle_set_mac sanity checks\n");
                err = -1;
                goto out_clean;
        }
 
 out_clean:
-       if (err_mac) {
-               printf("Something managed to set err_mac!\n");
-               err = -1;
-               free(err_mac);
-       }
-
        if (current_mac)
                free(current_mac);
        if (temp_mac)