On Sun, Feb 12, 2012 at 06:29:49PM -0800, Peter C. Wallace wrote: > 147 case 0x06: // byte stream > 148 buff = *pin->u32_pin & ((1 << conf->DataLength) - 1); > 149 break;
Hm, perhaps this is the correct replacement: buff = *pin->u32_pin & (0xffffffffu >> (32 - conf->DataLength)); I wrote the following program to verify the equivalence of this and the original-with-special-case for arguments of 1..32 inclusive: #include <assert.h> #include <stdint.h> uint32_t f1(int n) { if(n == 32) return 0xffffffffu; return (1 << n) - 1; } uint32_t f2(int n) { return 0xffffffffu >> (32 - n); } int main() { int i; for(i=1; i<32; i++) { assert(f1(i) == f2(i)); } return 0; } this moves the "shift 32 bits" case to correspond to a DataLength of 0, which probably represents misconfiguration. Jeff ------------------------------------------------------------------------------ Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 _______________________________________________ Emc-developers mailing list Emc-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-developers