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)
This commit is contained in:
Jurij Smakov 2006-11-11 14:09:15 +02:00 committed by Daniel Stone
parent ca09468419
commit acb5ff4c73
2 changed files with 5 additions and 0 deletions

View File

@ -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;

View File

@ -817,4 +817,7 @@ typedef struct {
extern int xstrcasecmp(char *s1, char *s2);
#endif
/* ffs.c */
extern int ffs(int i);
#endif /* DIX_H */