talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 28b9c8e65997b22d0d0c89ea5af000ad5edc5468
parent 7464133afbb78b20333a3067ed45ad7676406e96
Author: Jonathan Boeing <jonathan@claws-mail.org>
Date:   Wed, 29 Dec 2021 04:43:19 -0700

Fix -Wformat warnings

Diffstat:
Msrc/common/utils.h | 49++++++++++++++++++++++++++-----------------------
1 file changed, 26 insertions(+), 23 deletions(-)

diff --git a/src/common/utils.h b/src/common/utils.h @@ -103,11 +103,13 @@ typedef gint64 goffset; #define Xalloca(ptr, size, iffail) \ { \ - if (size > MAX_ALLOCA_MEM_SIZE) { \ - g_warning("%ld: Exceeds max allowed memory '%d'", size, MAX_ALLOCA_MEM_SIZE); \ - iffail; \ - } \ - if ((ptr = alloca(size)) == NULL) { \ + size_t __size = size; \ + \ + if (__size > MAX_ALLOCA_MEM_SIZE) { \ + g_warning("%" G_GSIZE_FORMAT " bytes exceeds max alloca size '%d'", __size, MAX_ALLOCA_MEM_SIZE); \ + iffail; \ + } \ + if ((ptr = alloca(__size)) == NULL) { \ g_warning("can't allocate memory"); \ iffail; \ } \ @@ -116,13 +118,13 @@ typedef gint64 goffset; #define Xstrdup_a(ptr, str, iffail) \ { \ gchar *__tmp; \ - ssize_t size = strlen(str); \ + size_t __size = strlen(str); \ \ - if (size > MAX_ALLOCA_MEM_SIZE) { \ - g_warning("%ld: Exceeds max allowed memory '%d'", size, MAX_ALLOCA_MEM_SIZE); \ - iffail; \ - } \ - if ((__tmp = alloca(size + 1)) == NULL) { \ + if (__size > MAX_ALLOCA_MEM_SIZE) { \ + g_warning("%" G_GSIZE_FORMAT " bytes exceeds max alloca size '%d'", __size, MAX_ALLOCA_MEM_SIZE); \ + iffail; \ + } \ + if ((__tmp = alloca(__size + 1)) == NULL) { \ g_warning("can't allocate memory"); \ iffail; \ } else \ @@ -134,17 +136,18 @@ typedef gint64 goffset; #define Xstrndup_a(ptr, str, len, iffail) \ { \ gchar *__tmp; \ + size_t __size = len; \ \ - if (len > MAX_ALLOCA_MEM_SIZE) { \ - g_warning("%ld: Exceeds max allowed memory '%d'", len, MAX_ALLOCA_MEM_SIZE); \ - iffail; \ - } \ - if ((__tmp = alloca(len + 1)) == NULL) { \ + if (__size > MAX_ALLOCA_MEM_SIZE) { \ + g_warning("%" G_GSIZE_FORMAT "bytes exceeds max alloca size '%d'", __size, MAX_ALLOCA_MEM_SIZE); \ + iffail; \ + } \ + if ((__tmp = alloca(__size + 1)) == NULL) { \ g_warning("can't allocate memory"); \ iffail; \ } else { \ - memcpy(__tmp, str, len); \ - __tmp[len] = '\0'; \ + memcpy(__tmp, str, __size); \ + __tmp[__size] = '\0'; \ } \ \ ptr = __tmp; \ @@ -153,14 +156,14 @@ typedef gint64 goffset; #define Xstrcat_a(ptr, str1, str2, iffail) \ { \ gchar *__tmp; \ - gint len1, len2; \ + size_t len1, len2; \ \ len1 = strlen(str1); \ len2 = strlen(str2); \ - if (len1 + len2 > MAX_ALLOCA_MEM_SIZE) { \ - g_warning("%ld: Exceeds max allowed memory '%d'", len1 + len2, MAX_ALLOCA_MEM_SIZE); \ - iffail; \ - } \ + if (len1 + len2 > MAX_ALLOCA_MEM_SIZE) { \ + g_warning("%" G_GSIZE_FORMAT " bytes exceeds max alloca size '%d'", len1 + len2, MAX_ALLOCA_MEM_SIZE); \ + iffail; \ + } \ if ((__tmp = alloca(len1 + len2 + 1)) == NULL) { \ g_warning("can't allocate memory"); \ iffail; \