From: Bruno Haible Date: Sat, 16 Jul 2011 00:51:48 +0000 (+0200) Subject: ffsl, ffsll: Avoid unportable behaviour. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b0c7231f53d33ed5559ef886b520a509a6893289;p=pspp ffsl, ffsll: Avoid unportable behaviour. * lib/ffsl.h (FUNC): Use 'unsigned int' instead of 'int'. --- diff --git a/ChangeLog b/ChangeLog index 9ee9bea80b..e97313b665 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-07-15 Bruno Haible + + ffsl, ffsll: Avoid unportable behaviour. + * lib/ffsl.h (FUNC): Use 'unsigned int' instead of 'int'. + 2011-07-15 Bruno Haible ffs: More tests. diff --git a/lib/ffsl.h b/lib/ffsl.h index 673b0aa2ba..eb7fead56d 100644 --- a/lib/ffsl.h +++ b/lib/ffsl.h @@ -39,9 +39,9 @@ FUNC (TYPE i) 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); } }