Skip to content

Commit

Permalink
pud: fix socket error
Browse files Browse the repository at this point in the history
Coverity:
CID 739663 (#2 of 2): Argument cannot be negative (NEGATIVE_RETURNS)
At (8): "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 4d4b879 commit 1aeaf0d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/pud/src/netTools.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ struct in_addr * getIPv4Address(const char * ifName, struct ifreq *ifr) {
assert(ifr != NULL);

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

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

0 comments on commit 1aeaf0d

Please sign in to comment.