]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
threads: minor code cleanups
authorVictor Julien <victor@inliniac.net>
Wed, 12 Jun 2019 07:57:02 +0000 (09:57 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 17 Jun 2019 18:06:50 +0000 (20:06 +0200)
src/tm-threads.c

index 895d3ed7fa95a7f9097cf0f556df9ed37d6ffb61..7e3ea98aaa2abb48e4778eaf60274739241f50b1 100644 (file)
@@ -785,14 +785,9 @@ error:
 
 ThreadVars *TmThreadsGetTVContainingSlot(TmSlot *tm_slot)
 {
-    ThreadVars *tv;
-    int i;
-
     SCMutexLock(&tv_root_lock);
-
-    for (i = 0; i < TVT_MAX; i++) {
-        tv = tv_root[i];
-
+    for (int i = 0; i < TVT_MAX; i++) {
+        ThreadVars *tv = tv_root[i];
         while (tv) {
             TmSlot *slots = tv->tm_slots;
             while (slots != NULL) {
@@ -805,9 +800,7 @@ ThreadVars *TmThreadsGetTVContainingSlot(TmSlot *tm_slot)
             tv = tv->next;
         }
     }
-
     SCMutexUnlock(&tv_root_lock);
-
     return NULL;
 }
 
@@ -871,16 +864,11 @@ void TmSlotSetFuncAppend(ThreadVars *tv, TmModule *tm, const void *data)
  */
 TmSlot *TmSlotGetSlotForTM(int tm_id)
 {
-    ThreadVars *tv = NULL;
-    TmSlot *slots;
-    int i;
-
     SCMutexLock(&tv_root_lock);
-
-    for (i = 0; i < TVT_MAX; i++) {
-        tv = tv_root[i];
+    for (int i = 0; i < TVT_MAX; i++) {
+        ThreadVars *tv = tv_root[i];
         while (tv) {
-            slots = tv->tm_slots;
+            TmSlot *slots = tv->tm_slots;
             while (slots != NULL) {
                 if (slots->tm_id == tm_id) {
                     SCMutexUnlock(&tv_root_lock);
@@ -891,9 +879,7 @@ TmSlot *TmSlotGetSlotForTM(int tm_id)
             tv = tv->next;
         }
     }
-
     SCMutexUnlock(&tv_root_lock);
-
     return NULL;
 }