cvs commit: src/sys/libkern ffs.c ffsl.c fls.c flsl.c

Stefan Farfeleder stefan at fafoe.narf.at
Tue Jan 13 11:33:37 PST 2004


On Tue, Jan 13, 2004 at 08:02:20AM -0800, Dag-Erling Smorgrav wrote:
> des         2004/01/13 08:02:20 PST
> 
>   FreeBSD src repository
> 
>   Modified files:
>     sys/libkern          ffs.c ffsl.c fls.c flsl.c 
>   Log:
>   Cast to unsigned to avoid sign-extension problems.
>   
>   Revision  Changes    Path
>   1.9       +1 -1      src/sys/libkern/ffs.c
>   1.2       +1 -1      src/sys/libkern/ffsl.c
>   1.2       +1 -1      src/sys/libkern/fls.c
>   1.2       +1 -1      src/sys/libkern/flsl.c

@@ -47,6 +47,6 @@ ffs(int mask)
 	if (mask == 0)
 		return (0);
 	for (bit = 1; !(mask & 1); bit++)
-		mask >>= 1;
+		(unsigned int)mask >>= 1;
 	return (bit);
 }

This is an ugly GCC extension.  Might I suggest using the portable

mask = (unsigned int)mask >> 1; 

instead?

Regards,
Stefan Farfeleder


More information about the cvs-all mailing list