From: Victor Julien Date: Mon, 16 Jan 2023 21:09:02 +0000 (+0100) Subject: src: fix unused-but-set-variable compile warnings X-Git-Tag: suricata-7.0.0-rc1~167 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1bc6976a061a78f953f6b9c796cd4135c1494beb;p=thirdparty%2Fsuricata.git src: fix unused-but-set-variable compile warnings Tested on Fedora 37 with clang 15. datasets.c:852:9: error: variable 'n' set but not used [-Werror,-Wunused-but-set-variable] int n = 0; ^ 1 error generated. --- diff --git a/src/datasets.c b/src/datasets.c index cd658d53ef..5fc9797a35 100644 --- a/src/datasets.c +++ b/src/datasets.c @@ -849,7 +849,6 @@ static void GetDefaultMemcap(uint64_t *memcap, uint32_t *hashsize) int DatasetsInit(void) { SCLogDebug("datasets start"); - int n = 0; ConfNode *datasets = ConfGetNode("datasets"); uint64_t default_memcap = 0; uint32_t default_hashsize = 0; @@ -916,7 +915,7 @@ int DatasetsInit(void) char conf_str[1024]; snprintf(conf_str, sizeof(conf_str), "datasets.%d.%s", list_pos, set_name); - SCLogDebug("(%d) set %s type %s. Conf %s", n, set_name, set_type->val, conf_str); + SCLogDebug("set %s type %s. Conf %s", set_name, set_type->val, conf_str); if (strcmp(set_type->val, "md5") == 0) { Dataset *dset = DatasetGet(set_name, DATASET_TYPE_MD5, save, load, @@ -926,9 +925,8 @@ int DatasetsInit(void) FatalErrorOnInit("failed to setup dataset for %s", set_name); continue; } - SCLogDebug("dataset %s: id %d type %s", set_name, n, set_type->val); + SCLogDebug("dataset %s: id %u type %s", set_name, dset->id, set_type->val); dset->from_yaml = true; - n++; } else if (strcmp(set_type->val, "sha256") == 0) { Dataset *dset = DatasetGet(set_name, DATASET_TYPE_SHA256, save, load, @@ -938,9 +936,8 @@ int DatasetsInit(void) FatalErrorOnInit("failed to setup dataset for %s", set_name); continue; } - SCLogDebug("dataset %s: id %d type %s", set_name, n, set_type->val); + SCLogDebug("dataset %s: id %u type %s", set_name, dset->id, set_type->val); dset->from_yaml = true; - n++; } else if (strcmp(set_type->val, "string") == 0) { Dataset *dset = DatasetGet(set_name, DATASET_TYPE_STRING, save, load, @@ -950,9 +947,8 @@ int DatasetsInit(void) FatalErrorOnInit("failed to setup dataset for %s", set_name); continue; } - SCLogDebug("dataset %s: id %d type %s", set_name, n, set_type->val); + SCLogDebug("dataset %s: id %u type %s", set_name, dset->id, set_type->val); dset->from_yaml = true; - n++; } list_pos++; diff --git a/src/detect-engine-enip.c b/src/detect-engine-enip.c index 245b68cfb3..117191597c 100644 --- a/src/detect-engine-enip.c +++ b/src/detect-engine-enip.c @@ -165,7 +165,9 @@ static int CIPPathMatch(CIPServiceEntry *svc, DetectCipServiceData *cipserviced) static int CIPServiceMatch(ENIPTransaction *enip_data, DetectCipServiceData *cipserviced) { +#ifdef DEBUG int count = 1; +#endif CIPServiceEntry *svc = NULL; //SCLogDebug("CIPServiceMatchAL"); TAILQ_FOREACH(svc, &enip_data->service_list, next) @@ -201,7 +203,9 @@ static int CIPServiceMatch(ENIPTransaction *enip_data, return 1; } } +#ifdef DEBUG count++; +#endif } return 0; } diff --git a/src/detect-engine-iponly.c b/src/detect-engine-iponly.c index ccfa650aca..41bdc2a0a5 100644 --- a/src/detect-engine-iponly.c +++ b/src/detect-engine-iponly.c @@ -447,8 +447,9 @@ static IPOnlyCIDRItem *IPOnlyCIDRItemInsert(IPOnlyCIDRItem *head, void IPOnlyCIDRListFree(IPOnlyCIDRItem *tmphead) { SCEnter(); +#ifdef DEBUG uint32_t i = 0; - +#endif IPOnlyCIDRItem *it, *next = NULL; if (tmphead == NULL) { @@ -460,8 +461,10 @@ void IPOnlyCIDRListFree(IPOnlyCIDRItem *tmphead) next = it->next; while (it != NULL) { +#ifdef DEBUG i++; SCLogDebug("Item(%p) %"PRIu32" removed", it, i); +#endif SCFree(it); it = next; diff --git a/src/detect-engine-port.c b/src/detect-engine-port.c index 9d7170e029..fe73395151 100644 --- a/src/detect-engine-port.c +++ b/src/detect-engine-port.c @@ -100,13 +100,16 @@ void DetectPortFree(const DetectEngineCtx *de_ctx, DetectPort *dp) void DetectPortPrintList(DetectPort *head) { DetectPort *cur; +#ifdef DEBUG uint16_t cnt = 0; - +#endif SCLogDebug("= list start:"); if (head != NULL) { for (cur = head; cur != NULL; cur = cur->next) { DetectPortPrint(cur); +#ifdef DEBUG cnt++; +#endif } SCLogDebug(" "); } diff --git a/src/detect-engine-sigorder.c b/src/detect-engine-sigorder.c index 819add6d7c..40b45eff26 100644 --- a/src/detect-engine-sigorder.c +++ b/src/detect-engine-sigorder.c @@ -730,8 +730,9 @@ void SCSigOrderSignatures(DetectEngineCtx *de_ctx) Signature *sig = NULL; SCSigSignatureWrapper *sigw = NULL; SCSigSignatureWrapper *sigw_list = NULL; - +#ifdef DEBUG int i = 0; +#endif SCLogDebug("ordering signatures in memory"); sig = de_ctx->sig_list; @@ -742,7 +743,9 @@ void SCSigOrderSignatures(DetectEngineCtx *de_ctx) sigw_list = sigw; sig = sig->next; +#ifdef DEBUG i++; +#endif } /* Sort the list */ @@ -754,9 +757,13 @@ void SCSigOrderSignatures(DetectEngineCtx *de_ctx) /* Recreate the sig list in order */ de_ctx->sig_list = NULL; sigw = sigw_list; +#ifdef DEBUG i = 0; +#endif while (sigw != NULL) { +#ifdef DEBUG i++; +#endif sigw->sig->next = NULL; if (de_ctx->sig_list == NULL) { /* First entry on the list */ diff --git a/src/flow-manager.c b/src/flow-manager.c index 273eeda721..92ce570f82 100644 --- a/src/flow-manager.c +++ b/src/flow-manager.c @@ -1188,8 +1188,6 @@ void FlowRecyclerThreadSpawn(void) */ void FlowDisableFlowRecyclerThread(void) { - int cnt = 0; - /* move all flows still in the hash to the recycler queue */ #ifndef DEBUG (void)FlowCleanupHash(); @@ -1211,7 +1209,6 @@ void FlowDisableFlowRecyclerThread(void) strlen(thread_name_flow_rec)) == 0) { TmThreadsSetFlag(tv, THV_KILL); - cnt++; } } SCMutexUnlock(&tv_root_lock); diff --git a/src/output-json-ftp.c b/src/output-json-ftp.c index 60e15e0e18..7177fb6a9d 100644 --- a/src/output-json-ftp.c +++ b/src/output-json-ftp.c @@ -74,7 +74,6 @@ static void EveFTPLogCommand(Flow *f, FTPTransaction *tx, JsonBuilder *jb) bool reply_truncated = false; if (!TAILQ_EMPTY(&tx->response_list)) { - int resp_code_cnt = 0; int resp_cnt = 0; FTPString *response; bool is_cc_array_open = false; @@ -102,7 +101,6 @@ static void EveFTPLogCommand(Flow *f, FTPTransaction *tx, JsonBuilder *jb) is_cc_array_open = true; } jb_append_string_from_bytes(jb, (const uint8_t *)where, 3); - resp_code_cnt++; offset = 4; } } diff --git a/src/util-device.c b/src/util-device.c index 313ce76d44..a7ef344e8f 100644 --- a/src/util-device.c +++ b/src/util-device.c @@ -284,7 +284,6 @@ static int LiveSafeDeviceName(const char *devname, char *newdevname, size_t dest */ LiveDevice *LiveGetDevice(const char *name) { - int i = 0; LiveDevice *pd; if (name == NULL) { @@ -296,8 +295,6 @@ LiveDevice *LiveGetDevice(const char *name) if (!strcmp(name, pd->dev)) { return pd; } - - i++; } return NULL; diff --git a/src/util-reference-config.c b/src/util-reference-config.c index e5ed88bfb4..e2adb49f64 100644 --- a/src/util-reference-config.c +++ b/src/util-reference-config.c @@ -320,8 +320,6 @@ static int SCRConfIsLineBlankOrComment(char *line) static bool SCRConfParseFile(DetectEngineCtx *de_ctx, FILE *fd) { char line[1024]; - uint8_t i = 1; - int runmode = RunmodeGetCurrent(); bool is_conf_test_mode = runmode == RUNMODE_CONF_TEST; while (fgets(line, sizeof(line), fd) != NULL) { @@ -333,7 +331,6 @@ static bool SCRConfParseFile(DetectEngineCtx *de_ctx, FILE *fd) return false; } } - i++; } #ifdef UNITTESTS