From: Jason Ish Date: Fri, 4 Oct 2024 23:21:34 +0000 (-0600) Subject: tm-modules: minor code cleanups X-Git-Tag: suricata-8.0.0-beta1~825 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F11880%2Fhead;p=thirdparty%2Fsuricata.git tm-modules: minor code cleanups - includes - loops --- 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;