]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/flow: minor code cleanups
authorVictor Julien <victor@inliniac.net>
Mon, 30 Jul 2018 17:27:09 +0000 (19:27 +0200)
committerVictor Julien <victor@inliniac.net>
Thu, 2 Aug 2018 09:21:32 +0000 (11:21 +0200)
src/detect-flow.c

index 88490285ae44369ae7496ac941e29570f16a929f..ad06d9e29a682e0dea7424f790584c78d78daa60 100644 (file)
@@ -152,7 +152,7 @@ int DetectFlowMatch (ThreadVars *t, DetectEngineThreadCtx *det_ctx, Packet *p,
 
     const DetectFlowData *fd = (const DetectFlowData *)ctx;
 
-    int ret = FlowMatch(p->flags, p->flowflags, det_ctx->flags, fd->flags, fd->match_cnt);;
+    const int ret = FlowMatch(p->flags, p->flowflags, det_ctx->flags, fd->flags, fd->match_cnt);
     SCLogDebug("returning %" PRId32 " fd->match_cnt %" PRId32 " fd->flags 0x%02X p->flowflags 0x%02X",
         ret, fd->match_cnt, fd->flags, p->flowflags);
     SCReturnInt(ret);
@@ -359,22 +359,17 @@ int DetectFlowSetupImplicit(Signature *s, uint32_t flags)
  */
 int DetectFlowSetup (DetectEngineCtx *de_ctx, Signature *s, const char *flowstr)
 {
-    DetectFlowData *fd = NULL;
-    SigMatch *sm = NULL;
-
-    fd = DetectFlowParse(flowstr);
-    if (fd == NULL)
-        goto error;
-
-    /*ensure only one flow option*/
+    /* ensure only one flow option */
     if (s->init_data->init_flags & SIG_FLAG_INIT_FLOW) {
         SCLogError (SC_ERR_INVALID_SIGNATURE, "A signature may have only one flow option.");
-        goto error;
+        return -1;
     }
 
-    /* Okay so far so good, lets get this into a SigMatch
-     * and put it in the Signature. */
-    sm = SigMatchAlloc();
+    DetectFlowData *fd = DetectFlowParse(flowstr);
+    if (fd == NULL)
+        return -1;
+
+    SigMatch *sm = SigMatchAlloc();
     if (sm == NULL)
         goto error;
 
@@ -406,8 +401,6 @@ int DetectFlowSetup (DetectEngineCtx *de_ctx, Signature *s, const char *flowstr)
 error:
     if (fd != NULL)
         DetectFlowFree(fd);
-    if (sm != NULL)
-        SCFree(sm);
     return -1;
 
 }