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:
parent
ca09468419
commit
acb5ff4c73
|
@ -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;
|
||||
|
|
|
@ -817,4 +817,7 @@ typedef struct {
|
|||
extern int xstrcasecmp(char *s1, char *s2);
|
||||
#endif
|
||||
|
||||
/* ffs.c */
|
||||
extern int ffs(int i);
|
||||
|
||||
#endif /* DIX_H */
|
||||
|
|
Loading…
Reference in New Issue
Block a user