[U-Boot] [PATCH] Use sizeof(gd_t), not sizeof(struct global_data)

The eNET (x86) build fails with "invalid application of 'sizeof' to incomplete type 'struct global_data'" because x86 doesn't define struct global_data. Change sizeof(struct global_data) to sizeof(gd_t) which is always available.
Cc: Graeme Russ graeme.russ@gmail.com Signed-off-by: Loïc Minier loic.minier@linaro.org --- lib/asm-offsets.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/asm-offsets.c b/lib/asm-offsets.c index 2209561..6a4084e 100644 --- a/lib/asm-offsets.c +++ b/lib/asm-offsets.c @@ -23,7 +23,7 @@ int main(void) { /* Round up to make sure size gives nice stack alignment */ DEFINE(GENERATED_GBL_DATA_SIZE, - (sizeof(struct global_data)+15) & ~15); + (sizeof(gd_t)+15) & ~15);
return 0; }

On Mon, Jan 3, 2011 at 10:47 AM, Loïc Minier wrote:
The eNET (x86) build fails with "invalid application of 'sizeof' to incomplete type 'struct global_data'" because x86 doesn't define struct global_data. Change sizeof(struct global_data) to sizeof(gd_t) which is always available.
why not change x86's global_data.h to define the struct ? all other arches define 'struct global_data'. -mike

On Mon, Jan 03, 2011, Mike Frysinger wrote:
why not change x86's global_data.h to define the struct ? all other arches define 'struct global_data'.
We could implement both fixes; there are two reasons I preferred sending this fix instead of the one you mention: * gd_t is used across the tree, while struct global_data is only used in arch/*/include/asm/global_data.h headers * the global_data.h header suggested that sizeof(gd_t) was an acceptable construct in a comment: GENERATED_GBL_DATA_SIZE > sizeof(gd_t)
I'll send an additional patch to also add struct global_data to arch/i386/include/asm/global_data.h.

Dear =?UTF-8?q?Lo=C3=AFc=20Minier?=,
In message 1294069652-9114-1-git-send-email-loic.minier@linaro.org you wrote:
The eNET (x86) build fails with "invalid application of 'sizeof' to incomplete type 'struct global_data'" because x86 doesn't define struct global_data. Change sizeof(struct global_data) to sizeof(gd_t) which is always available.
Um... I do not like this change; the resulting code is harder to read.
Can you please change the struct declaration isntead, like this:
diff --git a/arch/i386/include/asm/global_data.h b/arch/i386/include/asm/global_data.h index e3f8a25..e9000c3 100644 --- a/arch/i386/include/asm/global_data.h +++ b/arch/i386/include/asm/global_data.h @@ -35,7 +35,7 @@
#ifndef __ASSEMBLY__
-typedef struct { +typedef struct global_data { bd_t *bd; unsigned long flags; unsigned long baudrate;
Best regards,
Wolfgang Denk

On Mon, Jan 03, 2011, Wolfgang Denk wrote:
Um... I do not like this change; the resulting code is harder to read.
I don't mind either way; I had asked 20101220111358.GA28532@bee.dooz.org which one was the preferred approach, but didn't get comments on this particular point; see 20110103170050.GB10571@bee.dooz.org for the rationale for picking this option rather than the other one.
I've sent a second patch to also define struct global_data; feel free to cherry pick any of the two patches or both
Thanks!

The eNET (x86) build was failing to build with "invalid application of 'sizeof' to incomplete type 'struct global_data'" because x86 didn't define struct global_data. lib/asm-offsets.c was changed to use sizeof(gd_t) as gd_t is more commonly used outside of arch/*/include/asm/global_data.h, but it is still useful to define struct global_data in arch/i386/include/asm/global_data.h for consistency.
Signed-off-by: Loïc Minier loic.minier@linaro.org Cc: Graeme Russ graeme.russ@gmail.com --- arch/i386/include/asm/global_data.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/arch/i386/include/asm/global_data.h b/arch/i386/include/asm/global_data.h index e3f8a25..6b7e101 100644 --- a/arch/i386/include/asm/global_data.h +++ b/arch/i386/include/asm/global_data.h @@ -35,7 +35,7 @@
#ifndef __ASSEMBLY__
-typedef struct { +typedef struct global_data { bd_t *bd; unsigned long flags; unsigned long baudrate;
participants (4)
-
Loïc Minier
-
Loïc Minier
-
Mike Frysinger
-
Wolfgang Denk