]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
src: fix unused-but-set-variable compile warnings
authorVictor Julien <vjulien@oisf.net>
Mon, 16 Jan 2023 21:09:02 +0000 (22:09 +0100)
committerVictor Julien <vjulien@oisf.net>
Tue, 17 Jan 2023 10:25:44 +0000 (11:25 +0100)
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.

src/datasets.c
src/detect-engine-enip.c
src/detect-engine-iponly.c
src/detect-engine-port.c
src/detect-engine-sigorder.c
src/flow-manager.c
src/output-json-ftp.c
src/util-device.c
src/util-reference-config.c

index cd658d53ef0224fec1bbdd28a5f47ab7542beb68..5fc9797a35106346aeba377b23cc26926fea12a2 100644 (file)
@@ -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++;
index 245b68cfb35dc6e7838f35ac06954f786c39335a..117191597cdcce17592111f00d628612da574d0c 100644 (file)
@@ -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;
 }
index ccfa650acab2059f8e18a9f18b3ee66f70600e63..41bdc2a0a58553fa9808b688b269419b74dacc4e 100644 (file)
@@ -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;
 
index 9d7170e029176d1a231f247641946672b09e62ae..fe7339515100f4a7504b32bccc17077e2c2e1efe 100644 (file)
@@ -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(" ");
     }
index 819add6d7c1986a53478572465d80c30099d085b..40b45eff26d30e28435f93fc42dc6aa4e53d06a9 100644 (file)
@@ -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 */
index 273eeda721497572f8a04b029d004e0e53a47457..92ce570f8299285f3da548eb8e7bdb04f2fa835c 100644 (file)
@@ -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);
index 60e15e0e18477b5d5f9ecb906dd3e8d9d1db2c5e..7177fb6a9dbc91f09653a179fcb343af4d8a8fa9 100644 (file)
@@ -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;
                     }
                 }
index 313ce76d4478d0f3749392ae396ed3f69acacf48..a7ef344e8f28e1a91e24a625d8d8690d29c76327 100644 (file)
@@ -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;
index e5ed88bfb44c5b82a9a880f260ace22c4514edf8..e2adb49f64d710ef3ecdd3b58c1d7a35dc95222a 100644 (file)
@@ -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