summaryrefslogtreecommitdiff
path: root/src/truncate.c
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2008-06-26 11:10:13 +0100
committerJim Meyering <meyering@redhat.com>2008-06-27 08:11:21 +0200
commite2dbcee444e90e4289bd4bdc36783a5ef00af396 (patch)
treef5973cdb26c2e9d1f271b0c4bad69aae62dcac59 /src/truncate.c
parent8ce745dc612b21c01439da9a0ca217054841d177 (diff)
downloadcoreutils-e2dbcee444e90e4289bd4bdc36783a5ef00af396.tar.xz
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.
Diffstat (limited to 'src/truncate.c')
-rw-r--r--src/truncate.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/truncate.c b/src/truncate.c
index 2435a1277..02d41024b 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;