]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
eloop: fix some warnings
authorRoy Marples <roy@marples.name>
Tue, 7 Jan 2020 22:49:34 +0000 (22:49 +0000)
committerRoy Marples <roy@marples.name>
Tue, 7 Jan 2020 22:49:34 +0000 (22:49 +0000)
src/eloop.c

index e072fc24c738f1a2f8c4a6f50a9773842154c6ff..5a710aec72633ad2d6de44e96b17326805bec488 100644 (file)
@@ -1000,7 +1000,6 @@ eloop_start(struct eloop *eloop, sigset_t *signals)
        int n;
        struct eloop_event *e;
        struct eloop_timeout *t;
-       struct timespec ts, *tsp;
        void (*t0)(void *);
 #if defined(HAVE_KQUEUE)
        struct kevent ke;
@@ -1008,6 +1007,9 @@ eloop_start(struct eloop *eloop, sigset_t *signals)
 #elif defined(HAVE_EPOLL)
        struct epoll_event epe;
 #endif
+#if defined(HAVE_KQUEUE) || defined(HAVE_POLL)
+       struct timespec ts, *tsp;
+#endif
 #ifndef HAVE_KQUEUE
        int timeout;
 #endif
@@ -1041,6 +1043,7 @@ eloop_start(struct eloop *eloop, sigset_t *signals)
                }
 
                if (t != NULL) {
+#if defined(HAVE_KQUEUE) || defined(HAVE_POLL)
                        if (t->seconds > INT_MAX) {
                                ts.tv_sec = (time_t)INT_MAX;
                                ts.tv_nsec = 0;
@@ -1049,18 +1052,22 @@ eloop_start(struct eloop *eloop, sigset_t *signals)
                                ts.tv_nsec = t->nseconds;
                        }
                        tsp = &ts;
+#endif
 
 #ifndef HAVE_KQUEUE
                        if (t->seconds > INT_MAX / 1000 ||
-                           t->seconds == INT_MAX / 1000 &&
-                           ((t->nseconds + 999999) / 1000000 > INT_MAX % 1000000))
+                           (t->seconds == INT_MAX / 1000 &&
+                           ((t->nseconds + 999999) / 1000000
+                           > INT_MAX % 1000000)))
                                timeout = INT_MAX;
                        else
                                timeout = (int)(t->seconds * 1000 +
                                    (t->nseconds + 999999) / 1000000);
 #endif
                } else {
+#if defined(HAVE_KQUEUE) || defined(HAVE_POLL)
                        tsp = NULL;
+#endif
 #ifndef HAVE_KQUEUE
                        timeout = -1;
 #endif