]> granicus.if.org Git - strace/commitdiff
Partially revert last change
authorDenys Vlasenko <vda.linux@googlemail.com>
Tue, 20 Mar 2012 12:11:51 +0000 (13:11 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 20 Mar 2012 12:11:51 +0000 (13:11 +0100)
Thank you Dmitry for spotting it.

* ioctl.c (compare): Partially revert last change - the new
comparison logic was buggy.

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
ioctl.c

diff --git a/ioctl.c b/ioctl.c
index b63809386c97c17645523267f2092bd4ade0a614..dc412b6c1dd996c7891f8e8696bd29494761bde9 100644 (file)
--- a/ioctl.c
+++ b/ioctl.c
@@ -37,25 +37,7 @@ compare(const void *a, const void *b)
 {
        unsigned long code1 = (long) a;
        unsigned long code2 = ((struct ioctlent *) b)->code;
-
-       /* Simply returning (code1 - code2) may be wrong.
-        * Exmaple: 0xffffffff - 0 = 0xffffffff = -1.
-        * Need to shift both values down until they both fit
-        * in positive int.
-        */
-       while ((code1|code2) > INT_MAX) {
-#if INT_MAX == LONG_MAX
-               /* this case is easy */
-               code1 >>= 1;
-               code2 >>= 1;
-               break;
-#else
-               /* Remove INT_MAX worth of bits, then check again */
-               code1 >>= sizeof(int) * 8 - 1;
-               code2 >>= sizeof(int) * 8 - 1;
-#endif
-       }
-       return (int)code1 - (int)code2;
+       return (code1 > code2) ? 1 : (code1 < code2) ? -1 : 0;
 }
 
 const struct ioctlent *