]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
threads/time: minor code cleanup
authorVictor Julien <victor@inliniac.net>
Thu, 5 Mar 2020 10:05:12 +0000 (11:05 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 5 Mar 2020 10:06:56 +0000 (11:06 +0100)
src/tm-threads.c

index 15d9999db2498864f9c96864ebb9ca695de434ea..7146ad84c5a85ccf55eb3aa8f40c863f0f633fbe 100644 (file)
@@ -2216,7 +2216,6 @@ end:
     SCMutexUnlock(&thread_store_lock);
 }
 
-#define COPY_TIMESTAMP(src,dst) ((dst)->tv_sec = (src)->tv_sec, (dst)->tv_usec = (src)->tv_usec) // XXX unify with flow-util.h
 void TmThreadsSetThreadTimestamp(const int id, const struct timeval *ts)
 {
     SCMutexLock(&thread_store_lock);
@@ -2227,7 +2226,7 @@ void TmThreadsSetThreadTimestamp(const int id, const struct timeval *ts)
 
     int idx = id - 1;
     Thread *t = &thread_store.threads[idx];
-    COPY_TIMESTAMP(ts, &t->pktts);
+    t->pktts = *ts;
     struct timeval systs;
     gettimeofday(&systs, NULL);
     t->sys_sec_stamp = (uint32_t)systs.tv_sec;
@@ -2260,7 +2259,7 @@ void TmThreadsInitThreadsTimestamp(const struct timeval *ts)
         Thread *t = &thread_store.threads[s];
         if (!t->in_use)
             break;
-        COPY_TIMESTAMP(ts, &t->pktts);
+        t->pktts = *ts;
         t->sys_sec_stamp = (uint32_t)systs.tv_sec;
     }
     SCMutexUnlock(&thread_store_lock);
@@ -2287,21 +2286,19 @@ void TmThreadsGetMinimalTimestamp(struct timeval *ts)
                 continue;
 
             if (!set) {
-                local.tv_sec = t->pktts.tv_sec;
-                local.tv_usec = t->pktts.tv_usec;
+                local = t->pktts;
                 set = 1;
             } else {
                 if (timercmp(&t->pktts, &local, <)) {
-                    COPY_TIMESTAMP(&t->pktts, &local);
+                    local = t->pktts;
                 }
             }
         }
     }
     SCMutexUnlock(&thread_store_lock);
-    COPY_TIMESTAMP(&local, ts);
+    *ts = local;
     SCLogDebug("ts->tv_sec %"PRIuMAX, (uintmax_t)ts->tv_sec);
 }
-#undef COPY_TIMESTAMP
 
 /**
  *  \retval r 1 if packet was accepted, 0 otherwise