summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-08-10 19:01:54 +0000
committerJim Meyering <jim@meyering.net>2001-08-10 19:01:54 +0000
commitbffeb8c5aa3a2076646ca56d6324e4a21a459d1f (patch)
tree4df0d531244f662adffe4f896b4fa164ab867dab /src
parent97dcae2fb626e4d998113f5e0c8a33af9a55b0ce (diff)
downloadcoreutils-bffeb8c5aa3a2076646ca56d6324e4a21a459d1f.tar.xz
(print_long_format): Simplify previous patch for
listing negative sizes, by adding OFF_T_MAX - OFF_T_MIN + 1 instead of doing a fancy conditional shift. This is simpler and it avoids GCC's bogus compile-time warning about shift counts. (As a bonus, it is portable to hosts that do not use twos-complement arithmetic. :-)
Diffstat (limited to 'src')
-rw-r--r--src/ls.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/src/ls.c b/src/ls.c
index ec730d892..5065d5686 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -2642,13 +2642,7 @@ print_long_format (const struct fileinfo *f)
/* POSIX requires that the size be printed without a sign, even
when negative. Assume the typical case where negative sizes
are actually positive values that have wrapped around. */
- if (sizeof f->stat.st_size < sizeof size)
- size += ((uintmax_t) (f->stat.st_size < 0)
- << (sizeof f->stat.st_size * CHAR_BIT
- /* This final term has no effect other than to suppress
- a warning about the shift count being larger than the
- width of the type. */
- * (sizeof f->stat.st_size < sizeof size)));
+ size += (f->stat.st_size < 0) * ((uintmax_t) OFF_T_MAX - OFF_T_MIN + 1);
sprintf (p, "%8s ",
human_readable (size, hbuf, 1,