Hi,

Per style(9), macros with compound statements are easier used in
an if statement when do-loop wrapped.

--
Scott Cheloha

P.S. Is it just me or does the argument ordering for
TIMESPEC_TO_TIMEVAL seem backwards?

Index: sys/sys/time.h
===================================================================
RCS file: /cvs/src/sys/sys/time.h,v
retrieving revision 1.36
diff -u -p -r1.36 time.h
--- sys/sys/time.h      12 Sep 2016 19:41:20 -0000      1.36
+++ sys/sys/time.h      10 Dec 2017 04:35:28 -0000
@@ -60,14 +60,14 @@ struct timespec {
 };
 #endif
 
-#define        TIMEVAL_TO_TIMESPEC(tv, ts) {                                   
\
+#define        TIMEVAL_TO_TIMESPEC(tv, ts) do {                                
\
        (ts)->tv_sec = (tv)->tv_sec;                                    \
        (ts)->tv_nsec = (tv)->tv_usec * 1000;                           \
-}
-#define        TIMESPEC_TO_TIMEVAL(tv, ts) {                                   
\
+} while (0)
+#define        TIMESPEC_TO_TIMEVAL(tv, ts) do {                                
\
        (tv)->tv_sec = (ts)->tv_sec;                                    \
        (tv)->tv_usec = (ts)->tv_nsec / 1000;                           \
-}
+} while (0)
 
 struct timezone {
        int     tz_minuteswest; /* minutes west of Greenwich */

Reply via email to