Subject: Re: Endianness problem with u32 classifier hash masks

From: Jarek Poplawski <[email-masked]>
Date: Mon, 05 Nov 2007 22:28:46 +0100

Jarek Poplawski wrote, On 11/05/2007 10:06 PM:

> Radu Rendec wrote, On 11/05/2007 06:31 PM:

...

>> Jarek, because I have to test anyway, I'll include ffs(mask) in my patch
>> and have it tested too.
> 
> 
> Thanks! But, I did it wrong: + 1 is unnecessary. And since, ffs() checks
> for 0 anyway, this should be simpler:
> 
> - {
> - 	u8 i = 0;
> - 	u32 mask = s->hmask;
> - 	if (mask) {
> - 		while (!(mask & 1)) {
> - 			i++;
> - 			mask>>=1;
> - 		}
> - 	}
> - 	n->fshift = i;
> + 	n->fshift = ffs(s->hmask);
> - }
> 
> Plus maybe (u8) cast on warnings...
> 
> On the other hand, only now I see here is some hack (or bug) with this
> u8, so ffs() would mean a change here. I definitely need to rethink this.

> So, it's probably better to make and test this ffs() patch separately
> (2 parts).

Sorry, I'm only sleeping... u8 is fine of course, and it could be 1 part
as well, or as you like!

Jarek P.