changeset 15430:53f4964afb10

ffsl, ffsll: Avoid unportable behaviour. * lib/ffsl.h (FUNC): Use 'unsigned int' instead of 'int'.
author Bruno Haible <bruno@clisp.org>
date Sat, 16 Jul 2011 02:51:48 +0200
parents cb1d00b41a66
children 0d6da34844b5
files ChangeLog lib/ffsl.h
diffstat 2 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-07-15  Bruno Haible  <bruno@clisp.org>
+
+	ffsl, ffsll: Avoid unportable behaviour.
+	* lib/ffsl.h (FUNC): Use 'unsigned int' instead of 'int'.
+
 2011-07-15  Bruno Haible  <bruno@clisp.org>
 
 	ffs: More tests.
--- a/lib/ffsl.h
+++ b/lib/ffsl.h
@@ -39,9 +39,9 @@
     return 0;
   while (1)
     {
-      if ((int) j)
-        return result + ffs (j);
-      j >>= CHAR_BIT * sizeof (int);
-      result += CHAR_BIT * sizeof (int);
+      if ((unsigned int) j)
+        return result + ffs ((unsigned int) j);
+      j >>= CHAR_BIT * sizeof (unsigned int);
+      result += CHAR_BIT * sizeof (unsigned int);
     }
 }