]> The Tcpdump Group git mirrors - libpcap/commitdiff
Use %zu as the print format for size_t
authorFrancois-Xavier Le Bail <[email protected]>
Fri, 9 Aug 2019 07:53:24 +0000 (09:53 +0200)
committerFrancois-Xavier Le Bail <[email protected]>
Fri, 9 Aug 2019 08:02:38 +0000 (10:02 +0200)
C99 support it and also Visual Studio VS 2015 and after.

No more need for PRIsize format.

pcap/pcap-inttypes.h
savefile.c
sf-pcap.c
sf-pcapng.c

index 8b1eb8b9be848455ab1b0bb7fb9c215a2915e34e..af2c23c877edfd201d7e9ae96b382fd2563478d7 100644 (file)
       #define PRIu64   "llu"
     #endif
   #endif
-
-  /*
-   * MSVC's support library doesn't support %zu to print a size_t until
-   * Visual Studio 2017, but supports %Iu earlier, so use that.
-   */
-  #define PRIsize      "Iu"
 #elif defined(__MINGW32__) || !defined(_WIN32)
   /*
    * Compiler is MinGW or target is UN*X or MS-DOS.  Just use
    * <inttypes.h>.
    */
   #include <inttypes.h>
-
-  /*
-   * Assume the support library supports %zu; it's required by C99.
-   */
-  #define PRIsize      "zu"
 #endif
 
 #endif /* pcap/pcap-inttypes.h */
index a3db8ff4c1cfdab86063178f96a769aed7fb15e2..415e68449908b88f5ce047b2ad22bf65ac71bf92 100644 (file)
@@ -395,7 +395,7 @@ pcap_fopen_offline_with_tstamp_precision(FILE *fp, u_int precision,
                            errno, "error reading dump file");
                } else {
                        pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
-                           "truncated dump file; tried to read %" PRIsize " file header bytes, only got %" PRIsize,
+                           "truncated dump file; tried to read %zu file header bytes, only got %zu",
                            sizeof(magic), amt_read);
                }
                return (NULL);
index c48faf5da5041f7476508de483af57c38936b2ee..cb980ce729b5f6f370f01e2915659a605204e678 100644 (file)
--- a/sf-pcap.c
+++ b/sf-pcap.c
@@ -195,7 +195,7 @@ pcap_check_header(const uint8_t *magic, FILE *fp, u_int precision, char *errbuf,
                            errno, "error reading dump file");
                } else {
                        pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
-                           "truncated dump file; tried to read %" PRIsize " file header bytes, only got %" PRIsize,
+                           "truncated dump file; tried to read %zu file header bytes, only got %zu",
                            sizeof(hdr), amt_read);
                }
                *err = 1;
@@ -462,7 +462,7 @@ pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
                } else {
                        if (amt_read != 0) {
                                pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
-                                   "truncated dump file; tried to read %" PRIsize " header bytes, only got %" PRIsize,
+                                   "truncated dump file; tried to read %zu header bytes, only got %zu",
                                    ps->hdrsize, amt_read);
                                return (-1);
                        }
@@ -622,7 +622,7 @@ pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
                                 * the read finished.
                                 */
                                pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
-                                   "truncated dump file; tried to read %u captured bytes, only got %" PRIsize,
+                                   "truncated dump file; tried to read %u captured bytes, only got %zu",
                                    p->snapshot, amt_read);
                        }
                        return (-1);
@@ -646,7 +646,7 @@ pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
                                            "error reading dump file");
                                } else {
                                        pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
-                                           "truncated dump file; tried to read %u captured bytes, only got %" PRIsize,
+                                           "truncated dump file; tried to read %u captured bytes, only got %zu",
                                            hdr->caplen, bytes_read);
                                }
                                return (-1);
@@ -698,7 +698,7 @@ pcap_next_packet(pcap_t *p, struct pcap_pkthdr *hdr, u_char **data)
                                    "error reading dump file");
                        } else {
                                pcap_snprintf(p->errbuf, PCAP_ERRBUF_SIZE,
-                                   "truncated dump file; tried to read %u captured bytes, only got %" PRIsize,
+                                   "truncated dump file; tried to read %u captured bytes, only got %zu",
                                    hdr->caplen, amt_read);
                        }
                        return (-1);
index 997ad90419f1d4c5057e3db92cd5ad17747424de..92d00f802b1a4c1ff1147d3d53db202abc2e186e 100644 (file)
@@ -266,7 +266,7 @@ read_bytes(FILE *fp, void *buf, size_t bytes_to_read, int fail_on_eof,
                        if (amt_read == 0 && !fail_on_eof)
                                return (0);     /* EOF */
                        pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
-                           "truncated dump file; tried to read %" PRIsize " bytes, only got %" PRIsize,
+                           "truncated dump file; tried to read %zu bytes, only got %zu",
                            bytes_to_read, amt_read);
                }
                return (-1);
@@ -302,7 +302,7 @@ read_block(FILE *fp, pcap_t *p, struct block_cursor *cursor, char *errbuf)
        if (bhdr.total_length < sizeof(struct block_header) +
            sizeof(struct block_trailer)) {
                pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
-                   "block in pcapng dump file has a length of %u < %" PRIsize,
+                   "block in pcapng dump file has a length of %u < %zu",
                    bhdr.total_length,
                    sizeof(struct block_header) + sizeof(struct block_trailer));
                return (-1);
@@ -316,7 +316,7 @@ read_block(FILE *fp, pcap_t *p, struct block_cursor *cursor, char *errbuf)
                 * No.  Report that as an error.
                 */
                pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
-                   "block in pcapng dump file has a length of %u that is not a multiple of 4" PRIsize,
+                   "block in pcapng dump file has a length of %u that is not a multiple of 4",
                    bhdr.total_length);
                return (-1);
        }
@@ -858,7 +858,7 @@ pcap_ng_check_header(const uint8_t *magic, FILE *fp, u_int precision,
         */
        if (total_length < sizeof(*bhdrp) + sizeof(*shbp) + sizeof(struct block_trailer)) {
                pcap_snprintf(errbuf, PCAP_ERRBUF_SIZE,
-                   "Section Header Block in pcapng dump file has a length of %u < %" PRIsize,
+                   "Section Header Block in pcapng dump file has a length of %u < %zu",
                    total_length,
                    sizeof(*bhdrp) + sizeof(*shbp) + sizeof(struct block_trailer));
                *err = 1;