From: Victor Julien Date: Fri, 21 Jun 2019 13:50:36 +0000 (+0200) Subject: mem: avoid potential shadow vars with 'len' name X-Git-Tag: suricata-5.0.0-rc1~220 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a7d65668ae162518ba9843a38b24aa27240b43c9;p=thirdparty%2Fsuricata.git mem: avoid potential shadow vars with 'len' name --- diff --git a/src/util-mem.h b/src/util-mem.h index 7a71bc376f..1a80480ba2 100644 --- a/src/util-mem.h +++ b/src/util-mem.h @@ -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; \ })