Skip to content

Commit

Permalink
pud: fix socket error
Browse files Browse the repository at this point in the history
Coverity:
CID 739662 (#2 of 2): Argument cannot be negative (NEGATIVE_RETURNS)
At (9): "fd" is passed to a parameter that cannot be negative.

Signed-off-by: Ferry Huberts <[email protected]>
  • Loading branch information
fhuberts committed Oct 22, 2012
1 parent afd17ee commit 4d4b879
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/pud/src/netTools.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

/* System includes */
#include <sys/ioctl.h>
#include <errno.h>
#include <string.h>

/**
Get the hardware address (MAC) of an interface
Expand All @@ -33,6 +35,10 @@ unsigned char * getHardwareAddress(const char * ifName, int family,
assert(ifr != NULL);

fd = socket(family, SOCK_DGRAM, 0);
if (fd < 0) {
pudError(true, "%s@%u: socket error: %s", __FILE__, __LINE__, strerror(errno));
return NULL;
}

ifr->ifr_addr.sa_family = family;
memset(ifr->ifr_name, 0, sizeof(ifr->ifr_name));
Expand Down

0 comments on commit 4d4b879

Please sign in to comment.