Patchwork Remove warnings in nvramtool

login
register
about
Submitter Patrick Georgi
Date 2011-01-14 14:40:25
Message ID <1295016025.6246.14.camel@linux-0a8x.site>
Download mbox | patch
Permalink /patch/2519/
State Accepted
Commit r6266
Headers show

Comments

Patrick Georgi - 2011-01-14 14:40:25
Hi,

there are some strict aliasing related warnings in nvramtool.
This patch fixes them.


Signed-off-by: Patrick Georgi <patrick.georgi@secunet.com>
Stefan Reinauer - 2011-01-14 19:19:58
* Patrick Georgi <Patrick.Georgi@secunet.com> [110114 15:40]:
> Hi,
> 
> there are some strict aliasing related warnings in nvramtool.
> This patch fixes them.
> 
> 
> Signed-off-by: Patrick Georgi <patrick.georgi@secunet.com>

Acked-by: Stefan Reinauer <stepan@coreboot.org>

Patch

Index: util/nvramtool/lbtable.c

===================================================================
--- util/nvramtool/lbtable.c	(Revision 6254)

+++ util/nvramtool/lbtable.c	(Arbeitskopie)

@@ -360,7 +360,7 @@ 

 	       "    table_bytes:     0x%x (decimal: %d)\n"
 	       "    table_checksum:  0x%x (decimal: %d)\n"
 	       "    table_entries:   0x%x (decimal: %d)\n\n",
-	       vtophys(lbtable), *((uint32_t *) lbtable->signature),

+	       vtophys(lbtable), lbtable->signature32,

 	       lbtable->signature[0], lbtable->signature[1],
 	       lbtable->signature[2], lbtable->signature[3],
 	       lbtable->header_bytes, lbtable->header_bytes,
@@ -483,14 +483,14 @@ 

 					    int *bad_header_count,
 					    int *bad_table_count)
 {
-	static const char signature[] = { 'L', 'B', 'I', 'O' };

+	static const char signature[4] = { 'L', 'B', 'I', 'O' };

 	const struct lb_header *table;
 	const struct lb_forward *forward;
 	const uint32_t *p;
 	uint32_t sig;
 
 	assert(end >= start);
-	sig = (*((const uint32_t *)signature));

+	memcpy(&sig, signature, sizeof(sig));

 	table = NULL;
 	*bad_header_count = 0;
 	*bad_table_count = 0;
Index: util/nvramtool/coreboot_tables.h

===================================================================
--- util/nvramtool/coreboot_tables.h	(Revision 6254)

+++ util/nvramtool/coreboot_tables.h	(Arbeitskopie)

@@ -74,7 +74,10 @@ 

 }
 
 struct lb_header {
-	uint8_t signature[4];	/* LBIO */

+	union {

+		uint8_t signature[4];	/* LBIO */

+		uint32_t signature32;

+	};

 	uint32_t header_bytes;
 	uint32_t header_checksum;
 	uint32_t table_bytes;