talons

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

commit b7792aad0de10bd477e3b3ff936a3a915cdd2067
parent 67f11d6278e90c587aca21aa056a8f96a6ecd807
Author: Michael Rasmussen <mir@datanom.net>
Date:   Sun,  2 Jan 2022 16:12:56 +0100

Fix -Wformat warnings. Adapted patch for gtk3 branch by Jonathan Boeing

Signed-off-by: Michael Rasmussen <mir@datanom.net>

Diffstat:
Msrc/common/utils.h | 28+++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/src/common/utils.h b/src/common/utils.h @@ -103,8 +103,9 @@ 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); \ + 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) { \ @@ -116,13 +117,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); \ + 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) { \ + if ((__tmp = alloca(__size + 1)) == NULL) { \ g_warning("can't allocate memory"); \ iffail; \ } else \ @@ -134,17 +135,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); \ + 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(len + 1)) == NULL) { \ + 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,12 +155,12 @@ 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); \ + 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) { \