From: Victor Julien Date: Sun, 8 Oct 2017 16:28:30 +0000 (+0200) Subject: detect: minor cleanup X-Git-Tag: suricata-4.1.0-beta1~415 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ccf202a4f0acb2b46e4d2921129f22f66e329003;p=thirdparty%2Fsuricata.git detect: minor cleanup --- diff --git a/src/detect-engine-state.c b/src/detect-engine-state.c index 51ace58772..7e92bf7561 100644 --- a/src/detect-engine-state.c +++ b/src/detect-engine-state.c @@ -353,7 +353,8 @@ static void StoreStateTx(DetectEngineThreadCtx *det_ctx, SCLogDebug("Stored for TX %"PRIu64, tx_id); } -int DeStateDetectStartDetection(ThreadVars *tv, +/* returns: true match, false no match */ +bool DeStateDetectStartDetection(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, const Signature *s, Packet *p, Flow *f, @@ -365,7 +366,7 @@ int DeStateDetectStartDetection(ThreadVars *tv, /* TX based matches (inspect engines) */ void *alstate = FlowGetAppState(f); if (unlikely(!StateIsValid(alproto, alstate))) { - return 0; + return false; } SigMatchData *smd = NULL; @@ -511,7 +512,7 @@ int DeStateDetectStartDetection(ThreadVars *tv, det_ctx->tx_id = 0; det_ctx->tx_id_set = 0; det_ctx->p = NULL; - return alert_cnt ? 1:0; + return (alert_cnt > 0); } static int DoInspectItem(ThreadVars *tv, diff --git a/src/detect-engine-state.h b/src/detect-engine-state.h index 9497c80e91..860b0c8973 100644 --- a/src/detect-engine-state.h +++ b/src/detect-engine-state.h @@ -145,9 +145,9 @@ int DeStateFlowHasInspectableState(const Flow *f, const uint8_t flags); * \param flags Flags. * \param alproto App protocol. * - * \retval >= 0 An integer value indicating the no of matches. + * \retval bool true is sig matched, false if it didn't */ -int DeStateDetectStartDetection(ThreadVars *tv, DetectEngineCtx *de_ctx, +bool DeStateDetectStartDetection(ThreadVars *tv, DetectEngineCtx *de_ctx, DetectEngineThreadCtx *det_ctx, const Signature *s, Packet *p, Flow *f, const uint8_t flags, const AppProto alproto); diff --git a/src/detect.c b/src/detect.c index 8c05622112..c376867335 100644 --- a/src/detect.c +++ b/src/detect.c @@ -417,7 +417,6 @@ void SigMatchSignatures(ThreadVars *th_v, DetectEngineCtx *de_ctx, DetectEngineT uint8_t flow_flags = 0; /* flow/state flags */ const Signature *s = NULL; const Signature *next_s = NULL; - int state_alert = 0; bool app_decoder_events = false; bool has_state = false; /* do we have an alstate to work with? */ @@ -662,7 +661,7 @@ void SigMatchSignatures(ThreadVars *th_v, DetectEngineCtx *de_ctx, DetectEngineT } while (match_cnt--) { RULE_PROFILING_START(p); - state_alert = 0; + bool state_alert = false; #ifdef PROFILING bool smatch = false; /* signature match */ #endif @@ -867,7 +866,7 @@ void SigMatchSignatures(ThreadVars *th_v, DetectEngineCtx *de_ctx, DetectEngineT state_alert = DeStateDetectStartDetection(th_v, de_ctx, det_ctx, s, p, pflow, flow_flags, alproto); PACKET_PROFILING_DETECT_END(p, PROF_DETECT_STATEFUL_START); - if (state_alert == 0) + if (state_alert == false) goto next; /* match */