]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect: minor cleanup
authorVictor Julien <victor@inliniac.net>
Sun, 8 Oct 2017 16:28:30 +0000 (18:28 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 20 Dec 2017 09:51:29 +0000 (10:51 +0100)
src/detect-engine-state.c
src/detect-engine-state.h
src/detect.c

index 51ace587727017e796b0becd5e4abd7d155d0930..7e92bf7561fc7d5c341691d6ae6a90e8fb9020dd 100644 (file)
@@ -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,
index 9497c80e91717422f1819d623435f42bb80a69ce..860b0c89734d813c4e204e0f7615e904e9050955 100644 (file)
@@ -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);
index 8c056221121f2677bfb9024396b5c5d554584705..c3768673353dfc70c0d268dd25730b4becfa9466 100644 (file)
@@ -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 */