From 2fb56bbfaa9f6cc2787bb1f50a666bf65e7d227a Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 8 Oct 2014 16:34:31 +0000 Subject: [PATCH] * syscall.cc (ffs): Fix crash of ffs (0x80000000) on 64 bit. --- winsup/cygwin/ChangeLog | 4 ++++ winsup/cygwin/syscalls.cc | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index bd2eb01c9..c42766b93 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2014-10-08 Christian Franke + + * syscall.cc (ffs): Fix crash of ffs (0x80000000) on 64 bit. + 2014-10-08 Corinna Vinschen * fhandler_process.cc (format_process_statm): Fix output of dirty diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 15ebf4900..044e0036a 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -3847,10 +3847,9 @@ ffs (int i) 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8 }; - unsigned long int a; - unsigned long int x = i & -i; + unsigned x = i & -i; - a = x <= 0xffff ? (x <= 0xff ? 0 : 8) : (x <= 0xffffff ? 16 : 24); + int a = x <= 0xffff ? (x <= 0xff ? 0 : 8) : (x <= 0xffffff ? 16 : 24); return table[x >> a] + a; }