Project

General

Profile

Enhancement #750 » 0015-sanitize-add-bip_clock_gettime-util-function.patch

Loïc Gomez, 2022-01-10 19:28

View differences:

src/connection.c
list_t *wait_event(list_t *cn_list, time_t *msec, int *nc)
{
fd_set fds_read, fds_write, fds_except;
int maxfd = -1, err, errtime;
int maxfd = -1, err;
list_t *cn_newdata;
list_iterator_t it;
struct timeval tv;
......
mylog(LOG_DEBUGTOOMUCH, "msec: %d, sec: %d, usec: %d", *msec, tv.tv_sec,
tv.tv_usec);
errtime = clock_gettime(CLOCK_MONOTONIC, &btv);
if (errtime != 0) {
fatal("clock_gettime: %s", strerror(errno));
}
bip_clock_gettime(CLOCK_MONOTONIC, &btv);
err = select(maxfd + 1, &fds_read, &fds_write, &fds_except, &tv);
if (err == 0) {
......
tv.tv_sec, tv.tv_usec);
}
errtime = clock_gettime(CLOCK_MONOTONIC, &etv);
if (errtime != 0) {
fatal("clock_gettime: %s", strerror(errno));
}
bip_clock_gettime(CLOCK_MONOTONIC, &etv);
if (etv.tv_sec < btv.tv_sec)
mylog(LOG_ERROR, "Time rewinded ! not touching interval");
else {
src/util.c
return res;
}
void bip_clock_gettime(clockid_t clockid, struct timespec *tp)
{
int err = clock_gettime(clockid, tp);
if (err != 0)
fatal("clock_gettime: %s", strerror(errno));
if (tp->tv_sec < 0 || tp->tv_nsec < 0)
fatal("clock_gettime returned negative time");
}
/*
* <nick> ::= <letter> { <letter> | <number> | <special> }
* <special> ::= '-' | '[' | ']' | '\' | '`' | '^' | '{' | '}'
src/util.h
char *bip_strdup(const char *str);
char *bip_strcat_fit(size_t *remaining, char *str, const char *str2);
char *bip_strcatf_fit(size_t *remaining, char *str, const char *str2, ...);
void bip_clock_gettime(clockid_t clockid, struct timespec *tp);
#define array_each(a, idx, ptr) for ((idx) = 0; \
(idx) < (a)->elemc && (((ptr) = array_get((a), (idx))) || 1); \
(idx)++)
(14-14/24)