From: Victor Julien Date: Thu, 16 Aug 2018 12:57:20 +0000 (+0200) Subject: detect/mpm: clean up setup code X-Git-Tag: suricata-4.1.0-rc2~114 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7abb8745bfb01abc1c2453acd240685b8cc967ce;p=thirdparty%2Fsuricata.git detect/mpm: clean up setup code --- diff --git a/src/detect-engine-mpm.c b/src/detect-engine-mpm.c index 69977cc9e4..82fbe194aa 100644 --- a/src/detect-engine-mpm.c +++ b/src/detect-engine-mpm.c @@ -684,11 +684,10 @@ void RetrieveFPForSig(const DetectEngineCtx *de_ctx, Signature *s) memset(n_sm_list, 0, nlists * sizeof(int)); int count_nn_sm_list = 0; int count_n_sm_list = 0; - int list_id; /* inspect rule to see if we have the fast_pattern reg to * force using a sig, otherwise keep stats about the patterns */ - for (list_id = 0; list_id < nlists; list_id++) { + for (int list_id = 0; list_id < nlists; list_id++) { if (s->init_data->smlists[list_id] == NULL) continue; @@ -699,8 +698,7 @@ void RetrieveFPForSig(const DetectEngineCtx *de_ctx, Signature *s) if (sm->type != DETECT_CONTENT) continue; - DetectContentData *cd = (DetectContentData *)sm->ctx; - + const DetectContentData *cd = (DetectContentData *)sm->ctx; /* fast_pattern set in rule, so using this pattern */ if ((cd->flags & DETECT_CONTENT_FAST_PATTERN)) { SetMpm(s, sm); @@ -735,7 +733,7 @@ void RetrieveFPForSig(const DetectEngineCtx *de_ctx, Signature *s) int count_final_sm_list = 0; int priority; - SCFPSupportSMList *tmp = sm_fp_support_smlist_list; + const SCFPSupportSMList *tmp = sm_fp_support_smlist_list; while (tmp != NULL) { for (priority = tmp->priority; tmp != NULL && priority == tmp->priority; @@ -753,9 +751,8 @@ void RetrieveFPForSig(const DetectEngineCtx *de_ctx, Signature *s) BUG_ON(count_final_sm_list == 0); - int max_len = 0; - int i; - for (i = 0; i < count_final_sm_list; i++) { + uint16_t max_len = 0; + for (int i = 0; i < count_final_sm_list; i++) { if (final_sm_list[i] >= (int)s->init_data->smlists_array_size) continue; @@ -763,7 +760,7 @@ void RetrieveFPForSig(const DetectEngineCtx *de_ctx, Signature *s) if (sm->type != DETECT_CONTENT) continue; - DetectContentData *cd = (DetectContentData *)sm->ctx; + const DetectContentData *cd = (DetectContentData *)sm->ctx; /* skip_negated_content is only set if there's absolutely no * non-negated content present in the sig */ if ((cd->flags & DETECT_CONTENT_NEGATED) && skip_negated_content) @@ -773,7 +770,7 @@ void RetrieveFPForSig(const DetectEngineCtx *de_ctx, Signature *s) } } - for (i = 0; i < count_final_sm_list; i++) { + for (int i = 0; i < count_final_sm_list; i++) { if (final_sm_list[i] >= (int)s->init_data->smlists_array_size) continue; @@ -781,7 +778,7 @@ void RetrieveFPForSig(const DetectEngineCtx *de_ctx, Signature *s) if (sm->type != DETECT_CONTENT) continue; - DetectContentData *cd = (DetectContentData *)sm->ctx; + const DetectContentData *cd = (DetectContentData *)sm->ctx; /* skip_negated_content is only set if there's absolutely no * non-negated content present in the sig */ if ((cd->flags & DETECT_CONTENT_NEGATED) && skip_negated_content)