From 6b01b71e8370c58787318d5fca06db2074f95c55 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sun, 24 Jan 2010 22:52:21 +0100 Subject: randomconfig fixes Signed-off-by: Denys Vlasenko --- coreutils/ls.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'coreutils') diff --git a/coreutils/ls.c b/coreutils/ls.c index e7544474b..6c898b793 100644 --- a/coreutils/ls.c +++ b/coreutils/ls.c @@ -509,15 +509,10 @@ static int sortcmp(const void *a, const void *b) /* Make dif fit into an int */ if (sizeof(dif) > sizeof(int)) { - if (sizeof(dif) == sizeof(int)*2) { - /* typical on many arches */ - if (dif != 0) { - dif = 1 | (int)((uoff_t)dif >> (sizeof(int)*8)); - } - } else { - while ((dif & ~(off_t)INT_MAX) != 0) { - dif >>= (sizeof(int)*8 / 2); - } + enum { BITS_TO_SHIFT = 8 * (sizeof(dif) - sizeof(int)) }; + /* shift leaving only "int" worth of bits */ + if (dif != 0) { + dif = 1 | (int)((uoff_t)dif >> BITS_TO_SHIFT); } } -- cgit v1.2.3