On Sat, 17 Dec 2011, Dimitry Andric wrote:
Log:
In usr.bin/csup/proto.c, use the correct printf length modifier to print
an off_t.
...
Modified: head/usr.bin/csup/proto.c
==============================================================================
--- head/usr.bin/csup/proto.c Sat Dec 17 13:14:44 2011 (r228625)
+++ head/usr.bin/csup/proto.c Sat Dec 17 13:52:53 2011 (r228626)
...
@@ -751,7 +752,7 @@ proto_printf(struct stream *wr, const ch
break;
case 'O':
off = va_arg(ap, off_t);
- rv = stream_printf(wr, "%llu", off);
+ rv = stream_printf(wr, "%" PRId64, off);
break;
case 'S':
s = va_arg(ap, char *);
PRId64 is another incorrect printf format.
off_t is typedefed so that it can be changed as neccessary. Using
PRId64 hard-codes the assumption that it is precisely a 64 bit signed
integer. It is indeed a signed integer (POSIX 2001 standard). In
1990 POSIX, it was only required to be a signed arithmetic type, so
portable code had to handle the possibility that it was floating point,
and on systems with C90 compilers and 32-bit longs, it needed to be
floating point for it represent values a bit larger than 2**31-1.
In FreeBSD-1, it was 32 bits, so neither of the above would compile.
In FreeBSD[2-10], it is 64 bits integral. FreeBSD depended on using
a non-C90 compiler even to declare it, and never needed floating point
for it, except for strict C90 support it would have needed a compat
layer with the int64_t kernel off_t trranslated to a long double
userland off_t.
Bruce
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"