summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJurij Smakov <jurij@wooyd.org>2006-11-11 14:09:15 +0200
committerDaniel Stone <daniels@endtroducing.fooishbar.org>2006-11-11 14:13:56 +0200
commitacb5ff4c73ac4d52201d7c421f488e2ead5c8b9c (patch)
tree398635e5a72abd9679e1dcfd64023bbb5fa2ee2f
parentca094684196886a4a1c10273049fae0705a3edc2 (diff)
ffs: handle 0 argument (bug #8968)
Handle an argument of 0 in ffs(), instead of looping indefinitely. Add an ffs prototype to dix.h, and add includes to ffs.c. (cherry picked from 34164e551e4c3909322d50b09835ca4ac1d49d68 commit)
-rw-r--r--dix/ffs.c2
-rw-r--r--include/dix.h3
2 files changed, 5 insertions, 0 deletions
diff --git a/dix/ffs.c b/dix/ffs.c
index f84f7b47f..b75657d29 100644
--- a/dix/ffs.c
+++ b/dix/ffs.c
@@ -36,6 +36,8 @@ int
ffs(int i)
{
int j;
+ if (i == 0)
+ return 0;
for (j = 1; (i & 1) == 0; j++)
i >>= 1;
return j;
diff --git a/include/dix.h b/include/dix.h
index 983a84f02..a5a570a51 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -817,4 +817,7 @@ typedef struct {
extern int xstrcasecmp(char *s1, char *s2);
#endif
+/* ffs.c */
+extern int ffs(int i);
+
#endif /* DIX_H */