]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect/ipopt: Misc. cleanup
authorJeff Lucovsky <jlucovsky@oisf.net>
Thu, 21 Mar 2024 13:38:57 +0000 (09:38 -0400)
committerVictor Julien <victor@inliniac.net>
Wed, 17 Apr 2024 15:09:03 +0000 (17:09 +0200)
Minor changes to improve readability, remove extraneous include files.

src/detect-ipopts.c

index e4e9e22a36a3f015c40bef1f868a5b2eb788e106..746036b009a8b506e8029f9ae19c8312d4ad2164 100644 (file)
 
 #include "suricata-common.h"
 #include "suricata.h"
-#include "decode.h"
 
 #include "detect.h"
 #include "detect-parse.h"
 
-#include "flow-var.h"
-#include "decode-events.h"
-
-#include "util-debug.h"
-
 #include "detect-ipopts.h"
 #include "util-unittest.h"
 
@@ -193,7 +187,7 @@ static DetectIpOptsData *DetectIpOptsParse (const char *rawstr)
 {
     int i;
     DetectIpOptsData *de = NULL;
-    int found = 0;
+    bool found = false;
 
     pcre2_match_data *match = NULL;
     int ret = DetectParsePcreExec(&parse_regex, &match, rawstr, 0, 0);
@@ -204,13 +198,15 @@ static DetectIpOptsData *DetectIpOptsParse (const char *rawstr)
 
     for(i = 0; ipopts[i].ipopt_name != NULL; i++)  {
         if((strcasecmp(ipopts[i].ipopt_name,rawstr)) == 0) {
-            found = 1;
+            found = true;
             break;
         }
     }
 
-    if(found == 0)
+    if (!found) {
+        SCLogError("unknown IP option specified \"%s\"", rawstr);
         goto error;
+    }
 
     de = SCMalloc(sizeof(DetectIpOptsData));
     if (unlikely(de == NULL))
@@ -242,9 +238,7 @@ error:
  */
 static int DetectIpOptsSetup (DetectEngineCtx *de_ctx, Signature *s, const char *rawstr)
 {
-    DetectIpOptsData *de = NULL;
-
-    de = DetectIpOptsParse(rawstr);
+    DetectIpOptsData *de = DetectIpOptsParse(rawstr);
     if (de == NULL)
         goto error;
 
@@ -270,8 +264,9 @@ error:
  */
 void DetectIpOptsFree(DetectEngineCtx *de_ctx, void *de_ptr)
 {
-    DetectIpOptsData *de = (DetectIpOptsData *)de_ptr;
-    if(de) SCFree(de);
+    if (de_ptr) {
+        SCFree(de_ptr);
+    }
 }
 
 /*