From d8f73c921543beaf4fe24643504e5075d8e2744e Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Fri, 4 Oct 2024 17:21:34 -0600 Subject: [PATCH] tm-modules: minor code cleanups - includes - loops --- src/tm-modules.c | 51 +++++++++++++----------------------------------- 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/src/tm-modules.c b/src/tm-modules.c index dbab61fa88..0b3212eb74 100644 --- a/src/tm-modules.c +++ b/src/tm-modules.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2010 Open Information Security Foundation +/* Copyright (C) 2007-2024 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -23,22 +23,15 @@ * Thread Module functions */ -#include "suricata-common.h" -#include "packet-queue.h" -#include "tm-threads.h" +#include "tm-modules.h" #include "util-debug.h" -#include "threads.h" -#include "util-logopenfile.h" TmModule tmm_modules[TMM_SIZE]; void TmModuleDebugList(void) { - TmModule *t; - uint16_t i; - - for (i = 0; i < TMM_SIZE; i++) { - t = &tmm_modules[i]; + for (uint16_t i = 0; i < TMM_SIZE; i++) { + TmModule *t = &tmm_modules[i]; if (t->name == NULL) continue; @@ -52,11 +45,8 @@ void TmModuleDebugList(void) * \retval ptr to the module or NULL */ TmModule *TmModuleGetByName(const char *name) { - TmModule *t; - uint16_t i; - - for (i = 0; i < TMM_SIZE; i++) { - t = &tmm_modules[i]; + for (uint16_t i = 0; i < TMM_SIZE; i++) { + TmModule *t = &tmm_modules[i]; if (t->name == NULL) continue; @@ -78,7 +68,6 @@ TmModule *TmModuleGetByName(const char *name) */ TmModule *TmModuleGetById(int id) { - if (id < 0 || id >= TMM_SIZE) { SCLogError("Threading module with the id " "\"%d\" doesn't exist", @@ -98,11 +87,8 @@ TmModule *TmModuleGetById(int id) */ int TmModuleGetIDForTM(TmModule *tm) { - TmModule *t; - int i; - - for (i = 0; i < TMM_SIZE; i++) { - t = &tmm_modules[i]; + for (uint16_t i = 0; i < TMM_SIZE; i++) { + TmModule *t = &tmm_modules[i]; if (t->name == NULL) continue; @@ -117,11 +103,8 @@ int TmModuleGetIDForTM(TmModule *tm) void TmModuleRunInit(void) { - TmModule *t; - uint16_t i; - - for (i = 0; i < TMM_SIZE; i++) { - t = &tmm_modules[i]; + for (uint16_t i = 0; i < TMM_SIZE; i++) { + TmModule *t = &tmm_modules[i]; if (t->name == NULL) continue; @@ -135,11 +118,8 @@ void TmModuleRunInit(void) void TmModuleRunDeInit(void) { - TmModule *t; - uint16_t i; - - for (i = 0; i < TMM_SIZE; i++) { - t = &tmm_modules[i]; + for (uint16_t i = 0; i < TMM_SIZE; i++) { + TmModule *t = &tmm_modules[i]; if (t->name == NULL) continue; @@ -155,11 +135,8 @@ void TmModuleRunDeInit(void) void TmModuleRegisterTests(void) { #ifdef UNITTESTS - TmModule *t; - uint16_t i; - - for (i = 0; i < TMM_SIZE; i++) { - t = &tmm_modules[i]; + for (uint16_t i = 0; i < TMM_SIZE; i++) { + TmModule *t = &tmm_modules[i]; if (t->name == NULL) continue; -- 2.47.2