]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
mem: avoid potential shadow vars with 'len' name
authorVictor Julien <victor@inliniac.net>
Fri, 21 Jun 2019 13:50:36 +0000 (15:50 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 1 Jul 2019 13:44:30 +0000 (15:44 +0200)
src/util-mem.h

index 7a71bc376f53c41bd1a4813bd073c82c230866db..1a80480ba21c2318bef2827ed71c469457f23ab4 100644 (file)
@@ -135,22 +135,22 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
     char *ptrmem = NULL; \
     extern size_t global_mem; \
     extern uint8_t print_mem_flag; \
-    size_t len = strlen((a)); \
+    size_t _len = strlen((a)); \
     \
     ptrmem = strdup((a)); \
     if (ptrmem == NULL) { \
         SCLogError(SC_ERR_MEM_ALLOC, "SCStrdup failed: %s, while trying " \
-            "to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)len); \
+            "to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)_len); \
         if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\
             SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \
             exit(EXIT_FAILURE); \
         } \
     } \
     \
-    global_mem += len; \
+    global_mem += _len; \
     if (print_mem_flag == 1) {                              \
         SCLogInfo("SCStrdup return at %p of size %"PRIuMAX, \
-            ptrmem, (uintmax_t)len); \
+            ptrmem, (uintmax_t)_len);                       \
     }                                \
     (void*)ptrmem; \
 })
@@ -160,9 +160,9 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
     char *ptrmem = NULL; \
     extern size_t global_mem; \
     extern uint8_t print_mem_flag; \
-    size_t len = (b); \
+    size_t _len = (b); \
     \
-    size_t _scstrndup_len = len + 1; \
+    size_t _scstrndup_len = _len + 1; \
     ptrmem = (char *)malloc(_scstrndup_len); \
     if (ptrmem == NULL) { \
         SCLogError(SC_ERR_MEM_ALLOC, "SCStrndup failed: %s, while trying " \
@@ -172,8 +172,8 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
             exit(EXIT_FAILURE); \
         } \
     } else { \
-        strlcpy(ptrmem, (a), len); \
-        *(ptrmem + len) = '\0'; \
+        strlcpy(ptrmem, (a), _len); \
+        *(ptrmem + _len) = '\0'; \
     } \
     \
     global_mem += _scstrndup_len; \
@@ -188,22 +188,22 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
     char *ptrmem = NULL; \
     extern size_t global_mem; \
     extern uint8_t print_mem_flag; \
-    size_t len = (b); \
+    size_t _len = (b); \
     \
-    ptrmem = strndup((a), len); \
+    ptrmem = strndup((a), _len); \
     if (ptrmem == NULL) { \
         SCLogError(SC_ERR_MEM_ALLOC, "SCStrndup failed: %s, while trying " \
-            "to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)len); \
+            "to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)_len); \
         if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\
             SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \
             exit(EXIT_FAILURE); \
         } \
     } \
     \
-    global_mem += len; \
+    global_mem += _len; \
     if (print_mem_flag == 1) {                              \
         SCLogInfo("SCStrndup return at %p of size %"PRIuMAX, \
-            ptrmem, (uintmax_t)len); \
+            ptrmem, (uintmax_t)_len); \
     }                                \
     (void*)ptrmem; \
 })
@@ -284,9 +284,9 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
 #ifndef HAVE_STRNDUP
 #define SCStrndup(a, b) ({ \
     char *ptrmem = NULL; \
-    size_t len = (b); \
+    size_t _len = (b); \
     \
-    size_t _scstrndup_len = len + 1; \
+    size_t _scstrndup_len = _len + 1; \
     ptrmem = (char *)malloc(_scstrndup_len); \
     if (ptrmem == NULL) { \
         if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\
@@ -296,8 +296,8 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
             exit(EXIT_FAILURE); \
         } \
     } else { \
-        strlcpy(ptrmem, (a), len); \
-        *(ptrmem + len) = '\0'; \
+        strlcpy(ptrmem, (a), _len); \
+        *(ptrmem + _len) = '\0'; \
     } \
     (void*)ptrmem; \
 })