Author: blueswirl Date: 2009-08-23 14:40:22 +0200 (Sun, 23 Aug 2009) New Revision: 568
Modified: trunk/openbios-devel/drivers/fw_cfg.c trunk/openbios-devel/modules/pc-parts.c Log: Fix gcc 4.4 warnings about strict aliasing
Rather than cast char arrays to other types, use correct types and cast them to char pointers when needed.
Author: Pavel Roskin proski@gnu.org Signed-off-by: Blue Swirl blauwirbel@gmail.com
Modified: trunk/openbios-devel/drivers/fw_cfg.c =================================================================== --- trunk/openbios-devel/drivers/fw_cfg.c 2009-08-23 12:40:20 UTC (rev 567) +++ trunk/openbios-devel/drivers/fw_cfg.c 2009-08-23 12:40:22 UTC (rev 568) @@ -34,31 +34,31 @@ uint64_t fw_cfg_read_i64(uint16_t cmd) { - char buf[sizeof(uint64_t)]; + uint64_t buf;
- fw_cfg_read(cmd, buf, sizeof(uint64_t)); + fw_cfg_read(cmd, (char *)&buf, sizeof(uint64_t));
- return __le64_to_cpu(*(uint64_t *)buf); + return __le64_to_cpu(buf); }
uint32_t fw_cfg_read_i32(uint16_t cmd) { - char buf[sizeof(uint32_t)]; + uint32_t buf;
- fw_cfg_read(cmd, buf, sizeof(uint32_t)); + fw_cfg_read(cmd, (char *)&buf, sizeof(uint32_t));
- return __le32_to_cpu(*(uint32_t *)buf); + return __le32_to_cpu(buf); }
uint16_t fw_cfg_read_i16(uint16_t cmd) { - char buf[sizeof(uint16_t)]; + uint16_t buf;
- fw_cfg_read(cmd, buf, sizeof(uint16_t)); + fw_cfg_read(cmd, (char *)&buf, sizeof(uint16_t));
- return __le16_to_cpu(*(uint16_t *)buf); + return __le16_to_cpu(buf); }
void
Modified: trunk/openbios-devel/modules/pc-parts.c =================================================================== --- trunk/openbios-devel/modules/pc-parts.c 2009-08-23 12:40:20 UTC (rev 567) +++ trunk/openbios-devel/modules/pc-parts.c 2009-08-23 12:40:22 UTC (rev 568) @@ -58,8 +58,8 @@ unsigned char e_head; unsigned char e_sector; unsigned char e_cyl; - unsigned char start_sect[4]; /* unaligned little endian */ - unsigned char nr_sects[4]; /* ditto */ + u32 start_sect; /* unaligned little endian */ + u32 nr_sects; /* ditto */ } *p; unsigned char buf[512];
@@ -96,11 +96,11 @@ printk("partition %d does not exist\n", parnum+1 ); RET( 0 ); } - di->offs = (llong)(__le32_to_cpu(*((u32 *)p->start_sect))) * bs; - di->size = (llong)(__le32_to_cpu(*((u32 *)p->nr_sects))) * bs; + di->offs = (llong)(__le32_to_cpu(p->start_sect)) * bs; + di->size = (llong)(__le32_to_cpu(p->nr_sects)) * bs;
/* printk("Primary partition at sector %x\n", - __le32_to_cpu(*((u32 *)p->start_sect))); */ + __le32_to_cpu(p->start_sect)); */
RET( -1 ); } else { @@ -123,7 +123,7 @@ printk("Extended partition at %d\n", i+1);
/* Visit each logical partition labels */ - ext_start = __le32_to_cpu(*((u32 *)p[i].start_sect)); + ext_start = __le32_to_cpu(p[i].start_sect); cur_table = ext_start; cur_part = 4;
@@ -147,8 +147,8 @@ RET( 0 ); } di->offs = - (llong)(cur_table+__le32_to_cpu(*((u32 *)p->start_sect))) * bs; - di->size = (llong)__le32_to_cpu(*((u32 *)p->nr_sects)) * bs; + (llong)(cur_table+__le32_to_cpu(p->start_sect)) * bs; + di->size = (llong)__le32_to_cpu(p->nr_sects) * bs; RET ( -1 ); }
@@ -157,7 +157,7 @@ printk("no link\n"); break; } - cur_table = ext_start + __le32_to_cpu(*((u32 *)p[1].start_sect)); + cur_table = ext_start + __le32_to_cpu(p[1].start_sect);
cur_part++; }