tm-modules: minor code cleanups

- includes
- loops
pull/11880/head
Jason Ish 2 years ago
parent 415c5786de
commit d8f73c9215

@ -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 * You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free * the GNU General Public License version 2 as published by the Free
@ -23,22 +23,15 @@
* Thread Module functions * Thread Module functions
*/ */
#include "suricata-common.h" #include "tm-modules.h"
#include "packet-queue.h"
#include "tm-threads.h"
#include "util-debug.h" #include "util-debug.h"
#include "threads.h"
#include "util-logopenfile.h"
TmModule tmm_modules[TMM_SIZE]; TmModule tmm_modules[TMM_SIZE];
void TmModuleDebugList(void) void TmModuleDebugList(void)
{ {
TmModule *t; for (uint16_t i = 0; i < TMM_SIZE; i++) {
uint16_t i; TmModule *t = &tmm_modules[i];
for (i = 0; i < TMM_SIZE; i++) {
t = &tmm_modules[i];
if (t->name == NULL) if (t->name == NULL)
continue; continue;
@ -52,11 +45,8 @@ void TmModuleDebugList(void)
* \retval ptr to the module or NULL */ * \retval ptr to the module or NULL */
TmModule *TmModuleGetByName(const char *name) TmModule *TmModuleGetByName(const char *name)
{ {
TmModule *t; for (uint16_t i = 0; i < TMM_SIZE; i++) {
uint16_t i; TmModule *t = &tmm_modules[i];
for (i = 0; i < TMM_SIZE; i++) {
t = &tmm_modules[i];
if (t->name == NULL) if (t->name == NULL)
continue; continue;
@ -78,7 +68,6 @@ TmModule *TmModuleGetByName(const char *name)
*/ */
TmModule *TmModuleGetById(int id) TmModule *TmModuleGetById(int id)
{ {
if (id < 0 || id >= TMM_SIZE) { if (id < 0 || id >= TMM_SIZE) {
SCLogError("Threading module with the id " SCLogError("Threading module with the id "
"\"%d\" doesn't exist", "\"%d\" doesn't exist",
@ -98,11 +87,8 @@ TmModule *TmModuleGetById(int id)
*/ */
int TmModuleGetIDForTM(TmModule *tm) int TmModuleGetIDForTM(TmModule *tm)
{ {
TmModule *t; for (uint16_t i = 0; i < TMM_SIZE; i++) {
int i; TmModule *t = &tmm_modules[i];
for (i = 0; i < TMM_SIZE; i++) {
t = &tmm_modules[i];
if (t->name == NULL) if (t->name == NULL)
continue; continue;
@ -117,11 +103,8 @@ int TmModuleGetIDForTM(TmModule *tm)
void TmModuleRunInit(void) void TmModuleRunInit(void)
{ {
TmModule *t; for (uint16_t i = 0; i < TMM_SIZE; i++) {
uint16_t i; TmModule *t = &tmm_modules[i];
for (i = 0; i < TMM_SIZE; i++) {
t = &tmm_modules[i];
if (t->name == NULL) if (t->name == NULL)
continue; continue;
@ -135,11 +118,8 @@ void TmModuleRunInit(void)
void TmModuleRunDeInit(void) void TmModuleRunDeInit(void)
{ {
TmModule *t; for (uint16_t i = 0; i < TMM_SIZE; i++) {
uint16_t i; TmModule *t = &tmm_modules[i];
for (i = 0; i < TMM_SIZE; i++) {
t = &tmm_modules[i];
if (t->name == NULL) if (t->name == NULL)
continue; continue;
@ -155,11 +135,8 @@ void TmModuleRunDeInit(void)
void TmModuleRegisterTests(void) void TmModuleRegisterTests(void)
{ {
#ifdef UNITTESTS #ifdef UNITTESTS
TmModule *t; for (uint16_t i = 0; i < TMM_SIZE; i++) {
uint16_t i; TmModule *t = &tmm_modules[i];
for (i = 0; i < TMM_SIZE; i++) {
t = &tmm_modules[i];
if (t->name == NULL) if (t->name == NULL)
continue; continue;

Loading…
Cancel
Save