]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
threshold: minor code cleanups
authorVictor Julien <vjulien@oisf.net>
Tue, 8 Aug 2023 05:22:58 +0000 (07:22 +0200)
committerVictor Julien <vjulien@oisf.net>
Fri, 11 Aug 2023 05:02:06 +0000 (07:02 +0200)
src/util-threshold-config.c

index f19e8108d7ff33c96342cc7e54e20ccd064d9486..74e58fbc8c7622831fc080ffa8aad3fc835fab35 100644 (file)
@@ -25,8 +25,6 @@
  *
  * \author Breno Silva Pinto <breno.silva@gmail.com>
  *
- * \todo Need to support suppress
- *
  * Implements Threshold support
  */
 
@@ -177,7 +175,8 @@ int SCThresholdConfInitContext(DetectEngineCtx *de_ctx)
         filename = SCThresholdConfGetConfFilename(de_ctx);
         if ( (fd = fopen(filename, "r")) == NULL) {
             SCLogWarning("Error opening file: \"%s\": %s", filename, strerror(errno));
-            goto error;
+            SCThresholdConfDeInitContext(de_ctx, fd);
+            return 0;
         }
 #ifdef UNITTESTS
     }
@@ -185,11 +184,12 @@ int SCThresholdConfInitContext(DetectEngineCtx *de_ctx)
 
     if (SCThresholdConfParseFile(de_ctx, fd) < 0) {
         SCLogWarning("Error loading threshold configuration from %s", filename);
+        SCThresholdConfDeInitContext(de_ctx, fd);
         /* maintain legacy behavior so no errors unless config testing */
         if (RunmodeGetCurrent() == RUNMODE_CONF_TEST) {
             ret = -1;
         }
-        goto error;
+        return ret;
     }
     SCThresholdConfDeInitContext(de_ctx, fd);
 
@@ -198,11 +198,6 @@ int SCThresholdConfInitContext(DetectEngineCtx *de_ctx)
 #endif
     SCLogDebug("Global thresholding options defined");
     return 0;
-
-error:
-    SCThresholdConfDeInitContext(de_ctx, fd);
-
-return ret;
 }
 
 /**
@@ -929,10 +924,8 @@ static int SCThresholdConfAddThresholdtype(char *rawstr, DetectEngineCtx *de_ctx
     char *th_ip = NULL;
     uint32_t id = 0, gid = 0;
 
-    int r = 0;
-    r = ParseThresholdRule(de_ctx, rawstr, &id, &gid, &parsed_type, &parsed_track,
-                    &parsed_count, &parsed_seconds, &parsed_timeout, &parsed_new_action,
-                    &th_ip);
+    int r = ParseThresholdRule(de_ctx, rawstr, &id, &gid, &parsed_type, &parsed_track,
+            &parsed_count, &parsed_seconds, &parsed_timeout, &parsed_new_action, &th_ip);
     if (r < 0)
         goto error;
 
@@ -1051,7 +1044,6 @@ int SCThresholdConfParseFile(DetectEngineCtx *de_ctx, FILE *fp)
     }
 
     SCLogInfo("Threshold config parsed: %d rule(s) found", rule_num);
-
     return 0;
 }