On Sat, 15 Aug 2009, David Laight wrote:
On Sat, Aug 15, 2009 at 12:44:55PM +0000, Paul Goyette wrote:2. Replace a numeric constant with some sizeof's when calculating the size of the mode_select command buffer, clear the entire buffer, and KASSERT to ensure the page_0_size loaded from quirk table is valid.Are you sure the change doesn't break if the compiler adds any 'end of structure' padding ?
Yes, I'm certain that the change won't introduce any new breakage.In the specific instance here, replacing the original constant 12 with the two sizeof() changes nothing. If the compiler decides to insert some padding in the 'struct select { }', both the original constant and the replacement sizeof()s will be wrong, and by the same amount.
If the compiler decides to pad either of struct's members (which are also structs), then all bets are off since this 'struct select' is sent to the hardware. The lack of packing these sub-structs was discussed last week. Fortunately, all the sub-structs are composed of uint8_t members, and the two sub-structs in this particular piece of code are multiple of four bytes, so it's unlikely to be padded.
------------------------------------------------------------------------- | Paul Goyette | PGP DSS Key fingerprint: | E-mail addresses: | | Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com | | Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net | | Kernel Developer | | pgoyette at netbsd.org | -------------------------------------------------------------------------