const unsigned char *hp, *ep;
char *p;
- if (buf == NULL)
+ if (buf == NULL || hwlen == 0)
return NULL;
if (hwlen * 3 > buflen) {
v = 1;
if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &v, sizeof(v)) == -1)
- return -1;
+ goto errexit;
v = offsetof(struct udphdr, uh_sum);
if (setsockopt(fd, IPPROTO_IPV6, IPV6_CHECKSUM, &v, sizeof(v)) == -1)
- return -1;
+ goto errexit;
return fd;
+
+errexit:
+ close(fd);
+ return -1;
}
int
/* Don't use loginfo because this makes no sense in a log. */
if (!(loggetopts() & LOGERR_QUIET))
- fprintf(stderr, "forked to background, child pid %d\n",
+ (void)fprintf(stderr, "forked to background, child pid %d\n",
getpid());
i = EXIT_SUCCESS;
if (write(ctx->fork_fd, &i, sizeof(i)) == -1)
return 0;
i = (int)strtoi(buf, NULL, 0, INT_MIN, INT_MAX, &error);
if (error != 0)
- return -1;
- return error != 0 ? 0 : i;
+ return 0;
+ return i;
}
#endif /* INET6 */
errexit:
/* Failure to start root or inet processes is fatal. */
if (priv_fd == &ctx->ps_root_fd || priv_fd == &ctx->ps_inet_fd)
- ps_sendcmd(ctx, *priv_fd, PS_STOP, 0, NULL, 0);
+ (void)ps_sendcmd(ctx, *priv_fd, PS_STOP, 0, NULL, 0);
shutdown(*priv_fd, SHUT_RDWR);
*priv_fd = -1;
return -1;