mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-10 08:46:58 +08:00
Replaced redundant checked with asserts
Although the checks where strictly redundant, an update or restructuring of the loops/files could cause a signficant issues. For that keep them but within an assert() statement to be clear what it is about. Signed-off-by: Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
#include <netinet/ip.h>
|
||||
#include <poll.h>
|
||||
#include <limits.h>
|
||||
#include <assert.h>
|
||||
#include <nettle/sha1.h>
|
||||
#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;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <talloc.h>
|
||||
#include <assert.h>
|
||||
/* for inet_ntop */
|
||||
#include <arpa/inet.h>
|
||||
#include <syslog.h>
|
||||
@@ -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--;
|
||||
|
||||
Reference in New Issue
Block a user