Jim Meyering wrote: > Pádraig Brady <[EMAIL PROTECTED]> wrote: >> Jim Meyering wrote: >>> By the way, does %zu work reliably everywhere now? >>> In the past, we've converted such values to strings via umaxtostr, >>> to accommodate older systems. >>> >>> For ssize and nsize, I have a slight preference for the >>> cast-free approach of using %s with imaxtostr. >> Yes I suppose %z and PRIdMAX are C99 specific. >> How about the attached patch? > > Thanks! > However, I'd prefer to keep the use of PRIdMAX, > since gnulib's inttypes.h replacement lets us rely on that, > if you don't mind.
I'm a little confused. Did you change your mind and you now want to keep the (intmax_t) cast in my original patch? I also noticed that the use of size_t is buggy anyway in conjunction with off_t, so I've changed that. thanks, Pádraig.
>From ee15430cb9b0de578269262ee149aa9350184354 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?P=C3=A1draig=20Brady?= <[EMAIL PROTECTED]> Date: Thu, 26 Jun 2008 11:10:13 +0100 Subject: [PATCH] truncate: Fix integer portability issues * src/truncate.c: Explicitly convert from off_t to intmax_t when printing numbers as they may be different types. Also don't mix size_t and off_t types in operations as the latter will be promoted to unsigned when these types are the same size. --- src/truncate.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/truncate.c b/src/truncate.c index 2435a12..02d4102 100644 --- a/src/truncate.c +++ b/src/truncate.c @@ -155,12 +155,13 @@ do_ftruncate (int fd, char const *fname, off_t ssize, rel_mode_t rel_mode) } if (block_mode) { - size_t const blksize = ST_BLKSIZE (sb); + off_t const blksize = ST_BLKSIZE (sb); if (ssize < OFF_T_MIN / blksize || ssize > OFF_T_MAX / blksize) { error (0, 0, _("overflow in %" PRIdMAX - " * %zu byte blocks for file %s"), ssize, blksize, + " * %" PRIdMAX " byte blocks for file %s"), + (intmax_t) ssize, (intmax_t) blksize, quote (fname)); return 1; } @@ -241,7 +242,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, rel_mode_t rel_mode) { error (0, ftruncate_errno, _("truncating %s at %" PRIdMAX " bytes"), quote (fname), - nsize); + (intmax_t) nsize); return 1; } return 0; -- 1.5.3.6
_______________________________________________ Bug-coreutils mailing list Bug-coreutils@gnu.org http://lists.gnu.org/mailman/listinfo/bug-coreutils