diff mbox

[U-Boot,V4,2/3] tools: logo: add static and unused to bmp arrays

Message ID 1319089126-7358-3-git-send-email-clchiou@chromium.org
State Superseded
Delegated to: Anatolij Gustschin
Headers show

Commit Message

Che-liang Chiou Oct. 20, 2011, 5:38 a.m. UTC
The generated header bmp_logo.h is useful even outside common/lcd.c for
the logo dimension.  However, the problem is, the generated bmp_logo.h
cannot be included multiple times because bmp_logo_palette[] and
bmp_logo_bitmap[] are defined in the bmp_logo.h.

We may remedy this by adding
  static __attribute__((unused))
to the array definitions so that bmp_logo.h can be included multiple
times, and these arrays is used in only one inclusion (lcd.c).

Signed-off-by: Che-Liang Chiou <clchiou@chromium.org>
---

Changes in V4
  None

Changes in V3
  Add to the patch set

 tools/bmp_logo.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

Comments

Mike Frysinger Oct. 20, 2011, 12:42 p.m. UTC | #1
On Thursday 20 October 2011 01:38:45 Che-Liang Chiou wrote:
> The generated header bmp_logo.h is useful even outside common/lcd.c for
> the logo dimension.  However, the problem is, the generated bmp_logo.h
> cannot be included multiple times because bmp_logo_palette[] and
> bmp_logo_bitmap[] are defined in the bmp_logo.h.
> 
> We may remedy this by adding
>   static __attribute__((unused))
> to the array definitions so that bmp_logo.h can be included multiple
> times, and these arrays is used in only one inclusion (lcd.c).

i'm not sure this is the right way to go.  what if we split bmp_logo.h instead 
into bmp_logo_data.h (which has the array contents) and bmp_log.h (which has 
the defines and externs for the data arrays) ?
-mike
Wolfgang Denk Oct. 20, 2011, 6:43 p.m. UTC | #2
Dear Che-Liang Chiou,

in message <201110200842.02506.vapier@gentoo.org> Mike Frysinger wrote:
>
> i'm not sure this is the right way to go.  what if we split bmp_logo.h instead 
> into bmp_logo_data.h (which has the array contents) and bmp_log.h (which has 
> the defines and externs for the data arrays) ?

I support that suggestion.

Best regards,

Wolfgang Denk
diff mbox

Patch

diff --git a/tools/bmp_logo.c b/tools/bmp_logo.c
index 47228d2..3d11284 100644
--- a/tools/bmp_logo.c
+++ b/tools/bmp_logo.c
@@ -113,7 +113,8 @@  int main (int argc, char *argv[])
 		error ("Error allocating memory for file", fp);
 
 	/* read and print the palette information */
-	printf ("unsigned short bmp_logo_palette[] = {\n");
+	printf("static __attribute__((unused)) "
+			"unsigned short bmp_logo_palette[] = {\n");
 
 	for (i=0; i<n_colors; ++i) {
 		b->palette[(int)(i*3+2)] = fgetc(fp);
@@ -137,7 +138,8 @@  int main (int argc, char *argv[])
 	printf ("\n");
 	printf ("};\n");
 	printf ("\n");
-	printf ("unsigned char bmp_logo_bitmap[] = {\n");
+	printf("static __attribute__((unused)) "
+			"unsigned char bmp_logo_bitmap[] = {\n");
 	for (i=(b->height-1)*b->width; i>=0; i-=b->width) {
 		for (x = 0; x < b->width; x++) {
 			b->data[(uint16_t) i + x] = (uint8_t) fgetc (fp) \