Fix printf formats for size_t and goffset arguments.
authorAndrej Kacian <ticho@claws-mail.org>
Sat, 29 Dec 2018 13:23:03 +0000 (14:23 +0100)
committerAndrej Kacian <ticho@claws-mail.org>
Sat, 29 Dec 2018 13:23:03 +0000 (14:23 +0100)
Use G_GSIZE_FORMAT and G_GOFFSET_FORMAT macros
instead of hardcoded literal formats, because these
types can have different sizes on different platforms.

src/common/ssl_certificate.c
src/common/utils.c
src/etpan/imap-thread.c
src/etpan/nntp-thread.c
src/imap.c
src/msgcache.c
src/password.c
src/plugins/fancy/fancy_viewer.c
src/plugins/libravatar/libravatar_image.c
src/plugins/tnef_parse/tnef_parse.c
src/procmime.c

index 7c8a2442fa9092efc39434a5bafb1b581a444ca4..ebe6168187356bf3b6669aedcc8045546b134864 100644 (file)
@@ -176,11 +176,14 @@ static void gnutls_export_X509_fp(FILE *fp, gnutls_x509_crt_t x509_cert, gnutls_
        int r;
        
        if ((r = gnutls_x509_crt_export(x509_cert, format, output, &cert_size)) < 0) {
-               g_warning("couldn't export cert %s (%zd)", gnutls_strerror(r), cert_size);
+               g_warning("couldn't export cert %s (%"G_GSIZE_FORMAT")", gnutls_strerror(r), cert_size);
                return;
        }
-
+#ifdef G_OS_WIN32
+       debug_print("writing %Iu bytes\n",cert_size);
+#else
        debug_print("writing %zd bytes\n",cert_size);
+#endif
        if (claws_fwrite(&output, 1, cert_size, fp) < cert_size) {
                g_warning("failed to write cert: %d %s", errno, g_strerror(errno));
        }
@@ -197,7 +200,7 @@ size_t gnutls_i2d_X509(gnutls_x509_crt_t x509_cert, unsigned char **output)
        *output = malloc(cert_size);
 
        if ((r = gnutls_x509_crt_export(x509_cert, GNUTLS_X509_FMT_DER, *output, &cert_size)) < 0) {
-               g_warning("couldn't export cert %s (%zd)", gnutls_strerror(r), cert_size);
+               g_warning("couldn't export cert %s (%"G_GSIZE_FORMAT")", gnutls_strerror(r), cert_size);
                free(*output);
                *output = NULL;
                return 0;
@@ -216,7 +219,7 @@ size_t gnutls_i2d_PrivateKey(gnutls_x509_privkey_t pkey, unsigned char **output)
        *output = malloc(key_size);
 
        if ((r = gnutls_x509_privkey_export(pkey, GNUTLS_X509_FMT_DER, *output, &key_size)) < 0) {
-               g_warning("couldn't export key %s (%zd)", gnutls_strerror(r), key_size);
+               g_warning("couldn't export key %s (%"G_GSIZE_FORMAT")", gnutls_strerror(r), key_size);
                free(*output);
                *output = NULL;
                return 0;
@@ -510,7 +513,7 @@ static gboolean ssl_certificate_compare (SSLCertificate *cert_a, SSLCertificate
                return FALSE;
        }
        if (cert_size_a != cert_size_b) {
-               g_warning("size differ %zd %zd", cert_size_a, cert_size_b);
+               g_warning("size differ %"G_GSIZE_FORMAT" %"G_GSIZE_FORMAT, cert_size_a, cert_size_b);
                g_free(output_a);
                g_free(output_b);
                return FALSE;
index c4364c4bd59c47518052c8cbc7c684c57c66ee7f..ec87994ec0024d59da919a792d8c0aa46a557934 100644 (file)
@@ -4547,7 +4547,7 @@ guchar *g_base64_decode_zero(const gchar *text, gsize *out_len)
        g_free(tmp);
 
        if (strlen(out) != *out_len) {
-               g_warning ("strlen(out) %zd != *out_len %" G_GSIZE_FORMAT, strlen(out), *out_len);
+               g_warning ("strlen(out) %"G_GSIZE_FORMAT" != *out_len %"G_GSIZE_FORMAT, strlen(out), *out_len);
        }
 
        return out;
@@ -4617,7 +4617,7 @@ get_random_bytes(void *buf, size_t count)
        /* Read data from the source into buf. */
 #if defined G_OS_WIN32
        if (!CryptGenRandom(rnd, count, buf)) {
-               debug_print("Could not read %zd random bytes.\n", count);
+               debug_print("Could not read %"G_GSIZE_FORMAT" random bytes.\n", count);
                CryptReleaseContext(rnd, 0);
                return FALSE;
        }
index c6dd8018d0c4da259284118b59d39f44cef8f0ad..be5678cb8a2c185f5e3c0c47b38da1ca4e2213fb 100644 (file)
@@ -161,7 +161,7 @@ static void imap_logger_cmd(int direction, const char * str, size_t size)
        int i = 0;
 
        if (size > 8192) {
-               log_print(LOG_PROTOCOL, "IMAP%c [CMD data - %zd bytes]\n", direction?'>':'<', size);
+               log_print(LOG_PROTOCOL, "IMAP%c [CMD data - %"G_GSIZE_FORMAT" bytes]\n", direction?'>':'<', size);
                return;
        }
        buf = malloc(size+1);
@@ -196,7 +196,7 @@ static void imap_logger_fetch(int direction, const char * str, size_t size)
        int i = 0;
 
        if (size > 128 && !direction) {
-               log_print(LOG_PROTOCOL, "IMAP%c [FETCH data - %zd bytes]\n", direction?'>':'<', size);
+               log_print(LOG_PROTOCOL, "IMAP%c [FETCH data - %"G_GSIZE_FORMAT" bytes]\n", direction?'>':'<', size);
                return;
        }
        
@@ -222,7 +222,7 @@ static void imap_logger_fetch(int direction, const char * str, size_t size)
                        i++;
                }
        } else {
-               log_print(LOG_PROTOCOL, "IMAP%c [data - %zd bytes]\n", direction?'>':'<', size);
+               log_print(LOG_PROTOCOL, "IMAP%c [data - %"G_GSIZE_FORMAT" bytes]\n", direction?'>':'<', size);
        }
        g_strfreev(lines);
        free(buf);
@@ -235,7 +235,7 @@ static void imap_logger_uid(int direction, const char * str, size_t size)
        int i = 0;
 
        if (size > 8192) {
-               log_print(LOG_PROTOCOL, "IMAP%c [UID data - %zd bytes]\n", direction?'>':'<', size);
+               log_print(LOG_PROTOCOL, "IMAP%c [UID data - %"G_GSIZE_FORMAT" bytes]\n", direction?'>':'<', size);
                return;
        }
        buf = malloc(size+1);
@@ -277,10 +277,10 @@ static void imap_logger_append(int direction, const char * str, size_t size)
        int i = 0;
 
        if (size > 8192) {
-               log_print(LOG_PROTOCOL, "IMAP%c [APPEND data - %zd bytes]\n", direction?'>':'<', size);
+               log_print(LOG_PROTOCOL, "IMAP%c [APPEND data - %"G_GSIZE_FORMAT" bytes]\n", direction?'>':'<', size);
                return;
        } else if (direction == 0 && size > 64) {
-               log_print(LOG_PROTOCOL, "IMAP%c [APPEND data - %zd bytes]\n", direction?'>':'<', size);
+               log_print(LOG_PROTOCOL, "IMAP%c [APPEND data - %"G_GSIZE_FORMAT" bytes]\n", direction?'>':'<', size);
                return;
        } 
        buf = malloc(size+1);
@@ -305,7 +305,7 @@ static void imap_logger_append(int direction, const char * str, size_t size)
                        i++;
                }
        } else {
-               log_print(LOG_PROTOCOL, "IMAP%c [data - %zd bytes]\n", direction?'>':'<', size);
+               log_print(LOG_PROTOCOL, "IMAP%c [data - %"G_GSIZE_FORMAT" bytes]\n", direction?'>':'<', size);
        }
        g_strfreev(lines);
        free(buf);
index ccaede98d929b357c9218142eaed663335ae38d7..bf67cd004c0d2fb781392a81e41e8d840394741c 100644 (file)
@@ -136,7 +136,7 @@ static void nntp_logger(int direction, const char * str, size_t size)
        int i = 0;
 
        if (size > 256) {
-               log_print(LOG_PROTOCOL, "NNTP%c [data - %zd bytes]\n", direction?'>':'<', size);
+               log_print(LOG_PROTOCOL, "NNTP%c [data - %"G_GSIZE_FORMAT" bytes]\n", direction?'>':'<', size);
                return;
        }
        buf = malloc(size+1);
index 264dd7d8e61271a191f15b1f7399b77c15678aa6..db6770af0c243afdcbaf76d018477b93d7801156 100644 (file)
@@ -1587,7 +1587,7 @@ static gchar *imap_fetch_msg_full(Folder *folder, FolderItem *item, gint uid,
                                ok = file_strip_crs(filename);
                                if (ok == 0 && cached && cached->size <= have_size) {
                                        /* we have it all and stripped */
-                                       debug_print("...fully cached in fact (%u/%zd); setting flag.\n",
+                                       debug_print("...fully cached in fact (%u/%"G_GOFFSET_FORMAT"); setting flag.\n",
                                                        have_size, cached->size);
                                        procmsg_msginfo_set_flags(cached, MSG_FULLY_CACHED, 0);
                                }
@@ -1691,7 +1691,7 @@ static gboolean imap_is_msg_fully_cached(Folder *folder, FolderItem *item, gint
                size = get_file_size_with_crs(filename);
        }
        g_free(filename);
-       debug_print("msg %d cached, has size %d, full should be %zd.\n", uid, size, cached->size);
+       debug_print("msg %d cached, has size %d, full should be %"G_GOFFSET_FORMAT".\n", uid, size, cached->size);
        if (cached && size >= cached->size) {
                cached->total_size = cached->size;
                procmsg_msginfo_set_flags(cached, MSG_FULLY_CACHED, 0);
index 391025567f270cb79b0161790e0206972901ee17..fd0739773c7abd3a5ae564e1da3351a6867f72fd 100644 (file)
@@ -306,7 +306,7 @@ gint msgcache_get_memory_usage(MsgCache *cache)
        size_t ni; \
  \
        if ((ni = claws_fread(&idata, sizeof(idata), 1, fp)) != 1) { \
-               g_warning("read_int: Cache data corrupted, read %zd of %zd at " \
+               g_warning("read_int: Cache data corrupted, read %"G_GSIZE_FORMAT" of %"G_GSIZE_FORMAT" at " \
                          "offset %ld", ni, sizeof(idata), ftell(fp)); \
                procmsg_msginfo_free(&msginfo); \
                error = TRUE; \
@@ -467,16 +467,16 @@ static gint msgcache_read_cache_data_str(FILE *fp, gchar **str,
        if (!swapping) {
                if ((ni = claws_fread(&len, sizeof(len), 1, fp) != 1) ||
                    len > G_MAXINT) {
-                       g_warning("read_data_str: Cache data (len) corrupted, read %zd "
-                                 "of %zd bytes at offset %ld", ni, sizeof(len),
+                       g_warning("read_data_str: Cache data (len) corrupted, read %"G_GSIZE_FORMAT
+                                 " of %"G_GSIZE_FORMAT" bytes at offset %ld", ni, sizeof(len),
                                  ftell(fp));
                        return -1;
                }
        } else {
                if ((ni = claws_fread(&len, sizeof(len), 1, fp) != 1) ||
                    bswap_32(len) > G_MAXINT) {
-                       g_warning("read_data_str: Cache data (len) corrupted, read %zd "
-                                 "of %zd bytes at offset %ld", ni, sizeof(len),
+                       g_warning("read_data_str: Cache data (len) corrupted, read %"G_GSIZE_FORMAT
+                                 " of %"G_GSIZE_FORMAT" bytes at offset %ld", ni, sizeof(len),
                                  ftell(fp));
                        return -1;
                }
@@ -493,7 +493,7 @@ static gint msgcache_read_cache_data_str(FILE *fp, gchar **str,
        }
 
        if ((ni = claws_fread(tmpstr, 1, len, fp)) != len) {
-               g_warning("read_data_str: Cache data corrupted, read %zd of %u "
+               g_warning("read_data_str: Cache data corrupted, read %"G_GSIZE_FORMAT" of %u "
                          "bytes at offset %ld",
                          ni, len, ftell(fp));
                g_free(tmpstr);
index 463715b74cc8e7bda5ca0b78d009dcb6d9c832ab..8105820f8579e53d86eff394d7d0379720849521 100644 (file)
@@ -188,7 +188,7 @@ gboolean master_passphrase_is_correct(const gchar *input)
        g_strfreev(tokens);
 
        if (kd_len != KD_LENGTH) {
-               debug_print("master_passphrase is %ld bytes long, should be %d.\n",
+               debug_print("master_passphrase is %"G_GSIZE_FORMAT" bytes long, should be %d.\n",
                                kd_len, KD_LENGTH);
                g_free(kd);
                return FALSE;
@@ -488,7 +488,7 @@ gchar *password_decrypt_gnutls(const gchar *password,
                        g_free(tmp);
                return NULL;
        }
-       debug_print("Encrypted password string length: %lu\n", len);
+       debug_print("Encrypted password string length: %"G_GSIZE_FORMAT"\n", len);
 
        /* Initialize the decryption */
        ret = gnutls_cipher_init(&handle, algo, &key, &iv);
index 3792e846bbc767a298e03fc1e5c27cf9095a5c3d..a6eddb2f5e8802d9964d45eda56a0ce17c230a07 100644 (file)
@@ -457,7 +457,7 @@ static void resource_request_starting_cb(WebKitWebView              *view,
                webkit_network_request_set_uri(request, "about:blank");
        }
        else
-               debug_print("Starting request of %zu %s\n", strlen(uri), uri);
+               debug_print("Starting request of %"G_GSIZE_FORMAT" %s\n", strlen(uri), uri);
 }
 
 static gboolean fancy_text_search(MimeViewer *_viewer, gboolean backward,
index d36408ea77505517c8f95aef5f60f51fd53d7e8d..9a0338b603ba5e4852708f172051edd8fc6cae98 100644 (file)
@@ -37,7 +37,7 @@
 static size_t write_image_data_cb(void *ptr, size_t size, size_t nmemb, void *stream)
 {
        size_t written = claws_fwrite(ptr, size, nmemb, (FILE *)stream);
-       debug_print("received %zu bytes from avatar server\n", written);
+       debug_print("received %"G_GSIZE_FORMAT" bytes from avatar server\n", written);
 
        return written;
 }
index be8812d2a5f8c6cdd7dfaa7ecccee610abdd3b02..82a8f9e81ab5aaff737a9db3c9c975828e3bd4b5 100644 (file)
@@ -297,7 +297,7 @@ static gboolean tnef_parse (MimeParser *parser, MimeInfo *mimeinfo)
        if (mimeinfo->content == MIMECONTENT_FILE)
                debug_print("content: %s\n", mimeinfo->data.filename);
        else 
-               debug_print("contents in memory (len %zd)\n", 
+               debug_print("contents in memory (len %"G_GSIZE_FORMAT")\n", 
                        strlen(mimeinfo->data.mem));
        
        tnef = g_new0(TNEFStruct, 1);
index 484d6a411d3de00dafcb1c10465dbc084d58506d..e259adb0d3aaee332ff23b4ca718b59099b0aebb 100644 (file)
@@ -1270,7 +1270,7 @@ EncodingType procmime_get_encoding_for_text_file(const gchar *file, gboolean *ha
                octet_percentage = 0.0;
 
        debug_print("procmime_get_encoding_for_text_file(): "
-                   "8bit chars: %zd / %zd (%f%%)\n", octet_chars, total_len,
+                   "8bit chars: %"G_GSIZE_FORMAT" / %"G_GSIZE_FORMAT" (%f%%)\n", octet_chars, total_len,
                    100.0 * octet_percentage);
 
        if (octet_percentage > 0.20 || force_b64) {
@@ -2472,7 +2472,7 @@ static gint procmime_write_message_rfc822(MimeInfo *mimeinfo, FILE *fp)
                        }
                        len = strlen(buf);
                        if (claws_fwrite(buf, sizeof(gchar), len, fp) < len) {
-                               g_warning("failed to dump %zd bytes from file", len);
+                               g_warning("failed to dump %"G_GSIZE_FORMAT" bytes from file", len);
                                claws_fclose(infp);
                                return -1;
                        }
@@ -2484,7 +2484,7 @@ static gint procmime_write_message_rfc822(MimeInfo *mimeinfo, FILE *fp)
        case MIMECONTENT_MEM:
                len = strlen(mimeinfo->data.mem);
                if (claws_fwrite(mimeinfo->data.mem, sizeof(gchar), len, fp) < len) {
-                       g_warning("failed to dump %zd bytes from mem", len);
+                       g_warning("failed to dump %"G_GSIZE_FORMAT" bytes from mem", len);
                        return -1;
                }
                break;
@@ -2536,7 +2536,7 @@ static gint procmime_write_multipart(MimeInfo *mimeinfo, FILE *fp)
                                break;
                        len = strlen(buf);
                        if (claws_fwrite(buf, sizeof(gchar), len, fp) < len) {
-                               g_warning("failed to write %zd", len);
+                               g_warning("failed to write %"G_GSIZE_FORMAT, len);
                                claws_fclose(infp);
                                return -1;
                        }
@@ -2551,7 +2551,7 @@ static gint procmime_write_multipart(MimeInfo *mimeinfo, FILE *fp)
                        *(str2 - 2) = '\0';
                len = strlen(str);
                if (claws_fwrite(str, sizeof(gchar), len, fp) < len) {
-                       g_warning("failed to write %zd from mem", len);
+                       g_warning("failed to write %"G_GSIZE_FORMAT" from mem", len);
                        g_free(str);
                        return -1;
                }