On 27-Mar-2014 08:01, Tavmjong Bah wrote:
Hi all,
I have rewritten most of the style handling code in style.h and
One thing that should probably change in that file are these structs:
struct SPILengthOrNormal { unsigned set : 1; unsigned inherit : 1; unsigned normal : 1; unsigned unit : 4; float value; float computed; };
struct SPILength { unsigned set : 1; unsigned inherit : 1; unsigned unit : 4; float value; float computed; };
The problem is that one is often cast from the other, and the "normal" field falls within "unit". There is room for error there, with bits intended for one field ending up in the other. To avoid this sort of issue entirely it would be better if these were:
struct SPILength { unsigned set : 1; unsigned inherit : 1; unsigned unit : 4; unsigned unused : 26 float value; float computed; };
struct SPILengthOrNormal { unsigned set : 1; unsigned inherit : 1; unsigned unit : 4; unsigned normal : 1; unsigned unused : 25 float value; float computed; };
with all bits set to zero on creation. (Declaring the unused bit field isn't strictly necessary, but it sometimes makes it easier to debug memory access issues if every bit can be accessed by name.)
Regards,
David Mathog mathog@...1176... Manager, Sequence Analysis Facility, Biology Division, Caltech