diff --git a/src/common/common.c b/src/common/common.c index ce714652..aa942abd 100644 --- a/src/common/common.c +++ b/src/common/common.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include "common.h" #include "defs.h" @@ -254,7 +255,8 @@ ssize_t force_read(int sockfd, void *buf, size_t len) if (ret == -1) { if (errno != EAGAIN && errno != EINTR) return ret; - } else if (ret == 0 && left != 0) { + } else if (ret == 0) { + assert(left != 0); /* ensured by the while */ errno = ENOENT; return -1; } @@ -295,7 +297,8 @@ ssize_t force_read_timeout(int sockfd, void *buf, size_t len, unsigned sec) if (ret == -1) { if (errno != EAGAIN && errno != EINTR) return ret; - } else if (ret == 0 && left != 0) { + } else if (ret == 0) { + assert(left != 0); errno = ENOENT; return -1; } diff --git a/src/ip-util.c b/src/ip-util.c index 224a0f12..48a48bf6 100644 --- a/src/ip-util.c +++ b/src/ip-util.c @@ -21,6 +21,7 @@ #include #include #include +#include /* for inet_ntop */ #include #include @@ -218,7 +219,8 @@ char *human_addr2(const struct sockaddr *sa, socklen_t salen, if (salen == sizeof(struct sockaddr_in6)) { port = (unsigned)ntohs(((struct sockaddr_in6*)sa)->sin6_port); - if (full != 0 && port != 0 && buflen > 0) { + if (full != 0 && port != 0) { + assert(buflen > 0); /* already checked, but to avoid regression */ *buf = '['; buf++; buflen--;