Re: [PATCH -V3 08/11] arch/powerpc: Make some of the PGTABLE_RANGE dependency explicit
From: Paul Mackerras <hidden>
Date: 2012-07-23 00:20:19
On Mon, Jul 09, 2012 at 06:43:38PM +0530, Aneesh Kumar K.V wrote:
From: "Aneesh Kumar K.V" <redacted> slice array size and slice mask size depend on PGTABLE_RANGE. We can't directly include pgtable.h in these header because there is a circular dependency. So add compile time check for these values.
Some comments below...
struct slice_mask {
u16 low_slices;
/*
- * This should be derived out of PGTABLE_RANGE. For the current
- * max 64TB, u64 should be ok.
+ * We do this as a union so that we can verify
+ * SLICE_MASK_SIZE against PGTABLE_RANGE
*/
- u64 high_slices;
+ union {
+ u64 high_slices;
+ unsigned char not_used[SLICE_MASK_SIZE];
+ };Seems ugly to have to have a union just for that. Can't we do something like BUILD_BUG_ON(sizeof(u64) < SLICE_MASK_SIZE) instead?
quoted hunk ↗ jump to hunk
@@ -73,7 +73,7 @@ static struct slice_mask slice_range_to_mask(unsigned long start, unsigned long len) { unsigned long end = start + len - 1; - struct slice_mask ret = { 0, 0 }; + struct slice_mask ret = { 0, {0} };
Wouldn't { 0 } suffice? Similarly in several places below.
Paul.