Subject: Printing of off_t and size_t values
To: None <tech-misc@NetBSD.ORG>
From: Martin Husemann <firstname.lastname@example.org>
Date: 01/20/2003 10:47:51
A short discussion after a recent commit on source-changes brought this topic
up again and I tried to find all affected files (there are 235) - and then
noticed share/misc/style is among them. It suggests:
* To printf 64 bit quantities, use %ll and cast to (long long).
printf("The size of %s is %lld\n", p, (long long)sb->st_size);
Nowadays we can do better. I suggest to change this into:
* To printf size_t quantities, use %zd:
printf("The size of %s is %zd\n", p, sb->st_size);
* To printf off_t (or other 64 bit) quantities, use PRId64
* from <inttypes.h>:
printf("Read error at offset %" PRId64 "\n", o);
Is that OK?
One option is to leave out the first part and use PRId64 (and friends) always.
I volunteer to change all occurances in-tree to whatever we agree upon (skiping