On Sat, 2008-10-18 at 19:00 +0200, Michael Buesch wrote: > On Saturday 18 October 2008 16:53:57 Johannes Berg wrote: > > > + return (mask >> (attr-1)) & 0x1; > > > > I think > > > > return mask & (1<<(attr-1)); > > > > would be easier to understand. > > > I'm not sure if that would be correct. > The returned type is bool, which is 8bit. mask is 32bit. > So if attr is > 8 you end up with truncation, AFAICS. > > So it should be > > return !!(mask & (1<<(attr-1))); Indeed. > to explicitely convert the mask into a boolean with the LSB > indicating the state. > > But the original contruct isn't that bad, either, IMO :) True :) I just had to think about it for a moment, but that's ok :) johannes
Attachment:
signature.asc
Description: This is a digitally signed message part