Fixes for a bunch of compiler warnings.

This commit is contained in:
pdw
2014-01-05 20:02:51 +00:00
parent a7b8639fc9
commit 836733ba14
10 changed files with 22 additions and 95 deletions

View File

@@ -90,28 +90,23 @@ get_addrs_ioctl(char *interface, char if_hw_addr[], struct in_addr *if_ip_addr,
sysctlparam[5] = if_nametoindex(interface);
if (sysctlparam[5] == 0) {
fprintf(stderr, "Error getting hardware address for interface: %s\n", interface);
goto ENDHWADDR;
}
if (sysctl(sysctlparam, 6, NULL, &needed, NULL, 0) < 0) {
else if (sysctl(sysctlparam, 6, NULL, &needed, NULL, 0) < 0) {
fprintf(stderr, "Error getting hardware address for interface: %s\n", interface);
goto ENDHWADDR;
}
if ((buf = malloc(needed)) == NULL) {
else if ((buf = malloc(needed)) == NULL) {
fprintf(stderr, "Error getting hardware address for interface: %s\n", interface);
goto ENDHWADDR;
}
if (sysctl(sysctlparam, 6, buf, &needed, NULL, 0) < 0) {
else if (sysctl(sysctlparam, 6, buf, &needed, NULL, 0) < 0) {
fprintf(stderr, "Error getting hardware address for interface: %s\n", interface);
free(buf);
goto ENDHWADDR;
}
msghdr = (struct if_msghdr *) buf;
memcpy(if_hw_addr, LLADDR((struct sockaddr_dl *)(buf + sizeof(struct if_msghdr) - sizeof(struct if_data) + sizeof(struct if_data))), 6);
free(buf);
got_hw_addr = 1;
ENDHWADDR:
1; /* compiler whines if there is a label at the end of a block...*/
else {
msghdr = (struct if_msghdr *) buf;
memcpy(if_hw_addr, LLADDR((struct sockaddr_dl *)(buf + sizeof(struct if_msghdr) - sizeof(struct if_data) + sizeof(struct if_data))), 6);
free(buf);
got_hw_addr = 1;
}
}
#else
fprintf(stderr, "Cannot obtain hardware address on this platform\n");