Eliminate strict aliasing related warnings.
authorPatrick Georgi <patrick.georgi@secunet.com>
Tue, 18 Jan 2011 12:12:47 +0000 (12:12 +0000)
committerPatrick Georgi <patrick.georgi@coresystems.de>
Tue, 18 Jan 2011 12:12:47 +0000 (12:12 +0000)
Signed-off-by: Patrick Georgi <patrick.georgi@secunet.com>
Acked-by: Stefan Reinauer <stepan@coreboot.org>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@6266 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1

util/nvramtool/coreboot_tables.h
util/nvramtool/lbtable.c

index 08f0be63fab3ed55a90be8469a49446d2ebea47d..22570ac1f63e8067f8b4df23163408c68ef12b37 100644 (file)
@@ -74,7 +74,10 @@ static inline struct lb_uint64 pack_lb64(uint64_t value)
 }
 
 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;
index 88d7f9c1f47863c7eb240ca936c9004a1bd69f36..0a502a4722a21988b73bb174b1c8414b79ce994e 100644 (file)
@@ -360,7 +360,7 @@ void dump_lbtable(void)
               "    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 @@ static const struct lb_header *lbtable_scan(unsigned long start,
                                            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;