From: Jeff Lucovsky Date: Thu, 21 Mar 2024 13:38:57 +0000 (-0400) Subject: detect/ipopt: Misc. cleanup X-Git-Tag: suricata-8.0.0-beta1~1460 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c27dee7a9baf5b5c6697e80aef7f83a43dd3b709;p=thirdparty%2Fsuricata.git detect/ipopt: Misc. cleanup Minor changes to improve readability, remove extraneous include files. --- diff --git a/src/detect-ipopts.c b/src/detect-ipopts.c index e4e9e22a36..746036b009 100644 --- a/src/detect-ipopts.c +++ b/src/detect-ipopts.c @@ -25,16 +25,10 @@ #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); + } } /*