Skip to content

Commit

Permalink
[nozzle] fix a few coverity errors in the test suite
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
  • Loading branch information
fabbione committed Jul 25, 2019
1 parent a7d7757 commit bca3b8a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 6 additions & 2 deletions libnozzle/tests/api_nozzle_get_name_by_handle.c
Expand Up @@ -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;
}
Expand Down
14 changes: 5 additions & 9 deletions libnozzle/tests/api_nozzle_set_mac.c
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand All @@ -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)
Expand Down

0 comments on commit bca3b8a

Please sign in to comment.