rtadvd_check_timer() might return NULL if no timers need to run.
I'm not 100% sure if it can happen in practice though, but still...
Pointed out by llvm's scan-build.
OK?
diff --git rtadvd.c rtadvd.c
index 0152045..1af402b 100644
--- rtadvd.c
+++ rtadvd.c
@@ -154,7 +154,7 @@ main(int argc, char *argv[])
struct pollfd pfd[2];
struct timeval *timeout;
struct passwd *pw;
- int i, ch, npfd;
+ int i, ch, npfd, tmout;
log_init(1); /* log to stderr until daemonized */
@@ -247,16 +247,19 @@ main(int argc, char *argv[])
/* timer expiration check and reset the timer */
timeout = rtadvd_check_timer();
- if (timeout != NULL)
+ if (timeout != NULL) {
+ tmout = timeout->tv_sec * 1000 + timeout->tv_usec /
+ 1000;
log_debug("set timer to %lld.%ld. waiting for "
"inputs or timeout",
(long long)timeout->tv_sec,
timeout->tv_usec);
- else
+ } else {
+ tmout = INFTIM;
log_debug("there's no timer. waiting for inputs");
+ }
- if ((i = poll(pfd, npfd,
- timeout->tv_sec * 1000 + timeout->tv_usec / 1000)) < 0) {
+ if ((i = poll(pfd, npfd, tmout)) < 0) {
/* EINTR would occur upon SIGUSR1 for status dump */
if (errno != EINTR)
log_warn("poll");
--
I'm not entirely sure you are real.