summaryrefslogtreecommitdiff
path: root/sf-pcapng.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-08-05 15:59:44 -0700
committerGuy Harris <guy@alum.mit.edu>2018-08-05 15:59:44 -0700
commite217f88289b9601e3a9a8d13477f867bcb83b5e2 (patch)
tree76d6f0e719a8c8a6fbd0db055e0261d3a6c6f48d /sf-pcapng.c
parent90afc7640b08b812ff8e1f112e7dad7f690b0072 (diff)
downloadlibpcap-e217f88289b9601e3a9a8d13477f867bcb83b5e2.tar.gz
Add PRIsize, to use as the print format for size_t, and use it.
size_t may be bigger than unsigned long, so don't just cast to unsigned long and print with %lu". (In practice, the value is unlikely to be bigger, but this is cleaner.) We could use %zu on UN*X, as we require C99 support and C99 requires support for z as a size modifier, but MSVC doesn't support z as a size modifier until Visual Studio 2017.
Diffstat (limited to 'sf-pcapng.c')
-rw-r--r--sf-pcapng.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/sf-pcapng.c b/sf-pcapng.c
index 970c675c..06c896ac 100644
--- a/sf-pcapng.c
+++ b/sf-pcapng.c
@@ -261,9 +261,8 @@ 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 %lu bytes, only got %lu",
- (unsigned long)bytes_to_read,
- (unsigned long)amt_read);
+ "truncated dump file; tried to read %" PRIsize " bytes, only got %" PRIsize,
+ bytes_to_read, amt_read);
}
return (-1);
}
@@ -311,9 +310,9 @@ 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 < %lu",
+ "block in pcapng dump file has a length of %u < %" PRIsize,
bhdr.total_length,
- (unsigned long)(sizeof(struct block_header) + sizeof(struct block_trailer)));
+ sizeof(struct block_header) + sizeof(struct block_trailer));
return (-1);
}
@@ -831,9 +830,9 @@ pcap_ng_check_header(bpf_u_int32 magic, FILE *fp, u_int precision, char *errbuf,
*/
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 < %lu",
+ "Section Header Block in pcapng dump file has a length of %u < %" PRIsize,
total_length,
- (unsigned long)(sizeof(*bhdrp) + sizeof(*shbp) + sizeof(struct block_trailer)));
+ sizeof(*bhdrp) + sizeof(*shbp) + sizeof(struct block_trailer));
*err = 1;
return (NULL);
}