af-packet: fix cppcheck false positive

[src/source-af-packet.c:1903]: (error) Resource leak: fd
pull/2644/head
Victor Julien 8 years ago
parent 3726fd66be
commit 6227d0955f

@ -1886,7 +1886,9 @@ int AFPIsFanoutSupported(void)
{
#ifdef HAVE_PACKET_FANOUT
int fd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
if (fd != -1) {
if (fd < 0)
return 0;
uint16_t mode = PACKET_FANOUT_HASH | PACKET_FANOUT_FLAG_DEFRAG;
uint16_t id = 1;
uint32_t option = (mode << 16) | (id & 0xffff);
@ -1898,9 +1900,9 @@ int AFPIsFanoutSupported(void)
return 0;
}
return 1;
}
#endif
#else
return 0;
#endif
}
static int AFPCreateSocket(AFPThreadVars *ptv, char *devname, int verbose)

Loading…
Cancel
Save