Skip to contentSkip to conversation

drivers/bios_emulator: Fix gcc 4.4 compiler warning

PATCH New Kumar Gala 4 participants 14 messages Jul 13, 2009 – Aug 7, 2009 Block layer

lore
Share & tools
lore

Kumar Gala

author
#0 lore raw

PATCH 1/1 drivers/bios_emulator: Fix gcc 4.4 compiler warning

biosemu.c: In function 'BE_setVGA':
biosemu.c:147: warning: dereferencing type-punned pointer will break strict-aliasing rules

---
 drivers/bios_emulator/biosemu.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/bios_emulator/biosemu.c +2 -1
index d0c6521..cfa836c 100644
@@ -144,7 +144,8 @@ void X86API BE_setVGA(BE_VGAInfo * info)
 		_BE_env.biosmem_base = _BE_env.busmem_base + 0x20000;
 		_BE_env.biosmem_limit = 0xC7FFF;
 	}
-	if (*((u32 *) info->LowMem) == 0)
+	if ((info->LowMem[0] == 0) && (info->LowMem[1] == 0) &&
+	    (info->LowMem[2] == 0) && (info->LowMem[3] == 0))
 		_BE_bios_init((u32 *) info->LowMem);
 	memcpy((u8 *) M.mem_base, info->LowMem, sizeof(info->LowMem));
 }
Signature · 1 line
1.6.0.6
author
#1 lore raw

PATCH 1/1 ahci: Fix gcc 4.4 compiler warning

ahci.c: In function 'ata_scsiop_read_capacity10':
ahci.c:616: warning: dereferencing type-punned pointer will break strict-aliasing rules

---
 drivers/block/ahci.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)
drivers/block/ahci.c +6 -8
index e1b66fd..b0d1792 100644
@@ -602,7 +602,7 @@ static int ata_scsiop_read10(ccb * pccb)
  */
 static int ata_scsiop_read_capacity10(ccb *pccb)
 {
-	u8 buf[8];
+	u32 cap;
 
 	if (!ataid[pccb->target]) {
 		printf("scsi_ahci: SCSI READ CAPACITY10 command failure. "
@@ -611,14 +611,12 @@ static int ata_scsiop_read_capacity10(ccb *pccb)
 		return -EPERM;
 	}
 
-	memset(buf, 0, 8);
+	cap = le32_to_cpu(ataid[pccb->target]->lba_capacity);
+	memcpy(pccb->pdata, &cap, sizeof(cap));
 
-	*(u32 *) buf = le32_to_cpu(ataid[pccb->target]->lba_capacity);
-
-	buf[6] = 512 >> 8;
-	buf[7] = 512 & 0xff;
-
-	memcpy(pccb->pdata, buf, 8);
+	pccb->pdata[4] = pccb->pdata[5] = 0;
+	pccb->pdata[6] = 512 >> 8;
+	pccb->pdata[7] = 512 & 0xff;
 
 	return 0;
 }
Signature · 1 line
1.6.0.6
author
#2 lore raw

PATCH 1/1 dlmalloc: Ignore gcc4.4 compiler warnings

The version of dlmalloc we are using generates a fair number of warnings of the following form:

warning: dereferencing pointer '({anonymous})' does break strict-aliasing rules

Trying to fix these is just paper taping over the issue and we really just need to look into a new malloc implementation. So we disable these particular warning checks for dlmalloc.c only.

---
 common/Makefile |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
common/Makefile +1 -0
index c8e5d26..5b3490a 100644
@@ -34,6 +34,7 @@ COBJS-y += console.o
 COBJS-y += command.o
 COBJS-y += devices.o
 COBJS-y += dlmalloc.o
+CFLAGS_dlmalloc.o += -fno-strict-aliasing
 COBJS-y += exports.o
 COBJS-$(CONFIG_SYS_HUSH_PARSER) += hush.o
 COBJS-y += image.o
Signature · 1 line
1.6.0.6
#4 lore raw

PATCH 1/1 dlmalloc: Ignore gcc4.4 compiler warnings

In reply to Kumar Gala

Dear Kumar Gala,

Quoted 10 lines · In message <[email protected]> you…

The version of dlmalloc we are using generates a fair number of warnings of the following form:

warning: dereferencing pointer '({anonymous})' does break strict-aliasing rules

Trying to fix these is just paper taping over the issue and we really just need to look into a new malloc implementation. So we disable these particular warning checks for dlmalloc.c only.

Well, if you think fixing the problems is "paper taping over the issue", then how do you call NOT fixing the problems and shutting off the warnings?

NAK.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
If something is different, it's either better or worse,  and  usually
both.                                                    - Larry Wall
#5 lore raw

PATCH 1/1 dlmalloc: Ignore gcc4.4 compiler warnings

Quoted 12 lines · Wolfgang Denk

Dear Kumar Gala,

Quoted 9 lines · In message <[email protected]> you…

The version of dlmalloc we are using generates a fair number of warnings of the following form:

warning: dereferencing pointer '({anonymous})' does break strict-aliasing rules

Trying to fix these is just paper taping over the issue and we really just need to look into a new malloc implementation. So we disable these particular warning checks for dlmalloc.c only.

Quoted 5 lines
Quoted 1 line

Well, if you think fixing the problems is "paper taping over the issue", then how do you call NOT fixing the problems and shutting off the warnings?

Well he removed the optimization so the problem is no longer a problem. It's the description of what was done that is wrong.

#6 lore raw

PATCH 1/1 dlmalloc: Ignore gcc4.4 compiler warnings

Dear Kenneth Johansson,

Quoted 6 lines · In message <[email protected]> you wrote:
Quoted 4 lines

Well, if you think fixing the problems is "paper taping over the issue", then how do you call NOT fixing the problems and shutting off the warnings?

Well he removed the optimization so the problem is no longer a problem.

Of course it still is a problem. It has NOT been fixed - just hushed up.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
At the source of every error which is blamed on the computer you will
find at least two human errors, including the error of blaming it  on
the computer.
#7 lore raw

PATCH 1/1 dlmalloc: Ignore gcc4.4 compiler warnings

Quoted 4 lines · Wolfgang Denk

Dear Kenneth Johansson,

Quoted 1 line · In message <[email protected]> you wrote:
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

Well, if you think fixing the problems is "paper taping over the issue", then how do you call NOT fixing the problems and shutting off the warnings?

Well he removed the optimization so the problem is no longer a problem.

Of course it still is a problem. It has NOT been fixed - just hushed up.

The patch title is bad -- it's not disabling warnings, it's disabling an aspect of C99 that the code is incompatible with (and which is pretty questionable in the first place with such low level code). Note that in Linux, this is disabled for the entire kernel.

As things stand, GCC may do bad things with that code. With this patch, it may not (at least not this particular sort of bad thing). Those bad things are not limited to the places where it warns -- those are just the violations it detected.

Do you have an alternative malloc implementation in mind that is designed to work with strict aliasing, or a suggested fix to the current one?

-Scott

#8 lore raw

PATCH 1/1 dlmalloc: Ignore gcc4.4 compiler warnings

Dear Scott,

Quoted 5 lines · In message <[email protected]> you wrote:

The patch title is bad -- it's not disabling warnings, it's disabling an aspect of C99 that the code is incompatible with (and which is pretty questionable in the first place with such low level code). Note that in Linux, this is disabled for the entire kernel.

I know. But Linux is bigger than U-Boot, and I think we should be able to fix the few isolated places that throw such warnings.

Quoted 4 lines

As things stand, GCC may do bad things with that code. With this patch, it may not (at least not this particular sort of bad thing). Those bad things are not limited to the places where it warns -- those are just the violations it detected.

Agreed, and that's why I want to see this fixed.

Quoted 2 lines

Do you have an alternative malloc implementation in mind that is designed to work with strict aliasing, or a suggested fix to the current one?

I did not look into this yet - there was some discussion about a malloc replacement, but it faded away without visible result.

I cannot do everything myself, but I can oppose changes that are IMO to the worse.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I express preference for a chronological  sequence  of  events  which
precludes a violence.   - Terry Pratchett, _The Dark Side of the Sun_
author
#9 lore raw

PATCH 1/1 dlmalloc: Ignore gcc4.4 compiler warnings

Quoted 29 lines · Wolfgang Denk

Dear Scott,

In message <[email protected]> you

Quoted 7 lines · wrote:

The patch title is bad -- it's not disabling warnings, it's disabling an
aspect of C99 that the code is incompatible with (and which is pretty questionable in the first place with such low level code). Note that in
Linux, this is disabled for the entire kernel.

I know. But Linux is bigger than U-Boot, and I think we should be able to fix the few isolated places that throw such warnings.

Quoted 7 lines

As things stand, GCC may do bad things with that code. With this patch,
it may not (at least not this particular sort of bad thing). Those bad
things are not limited to the places where it warns -- those are just the
violations it detected.

Agreed, and that's why I want to see this fixed.

Quoted 3 lines

Do you have an alternative malloc implementation in mind that is designed
to work with strict aliasing, or a suggested fix to the current one?

Quoted 5 lines

I did not look into this yet - there was some discussion about a malloc replacement, but it faded away without visible result.

I cannot do everything myself, but I can oppose changes that are IMO to the worse.

Do we have any ideas what type of performance we're looking for from malloc?

- k

#10 lore raw

PATCH 1/1 dlmalloc: Ignore gcc4.4 compiler warnings

In reply to Wolfgang Denk
Quoted 12 lines · Wolfgang Denk

Dear Scott,

Quoted 5 lines · In message <[email protected]> you wrote:

The patch title is bad -- it's not disabling warnings, it's disabling an aspect of C99 that the code is incompatible with (and which is pretty questionable in the first place with such low level code). Note that in Linux, this is disabled for the entire kernel.

I know. But Linux is bigger than U-Boot, and I think we should be able to fix the few isolated places that throw such warnings.

Quoted 6 lines
Quoted 4 lines

As things stand, GCC may do bad things with that code. With this patch, it may not (at least not this particular sort of bad thing). Those bad things are not limited to the places where it warns -- those are just the violations it detected.

Agreed, and that's why I want to see this fixed.

Personally I feel this optimization to be in the "luxury" category. I'm not sure it's worth the trouble in a project like u-boot. Maybe it should be default off and only turned on for specific modules. like checksum and compression stuff.

author
#11 lore raw

PATCH 1/1 dlmalloc: Ignore gcc4.4 compiler warnings

In reply to Wolfgang Denk
Quoted 23 lines · Wolfgang Denk

Dear Scott,

In message <[email protected]> you

Quoted 7 lines · wrote:

The patch title is bad -- it's not disabling warnings, it's disabling an
aspect of C99 that the code is incompatible with (and which is pretty questionable in the first place with such low level code). Note that in
Linux, this is disabled for the entire kernel.

I know. But Linux is bigger than U-Boot, and I think we should be able to fix the few isolated places that throw such warnings.

Quoted 7 lines

As things stand, GCC may do bad things with that code. With this patch,
it may not (at least not this particular sort of bad thing). Those bad
things are not limited to the places where it warns -- those are just the
violations it detected.

Quoted 1 line

Agreed, and that's why I want to see this fixed.

I can understand that desire, however it seems a lot of our platforms are already globally turning on -fno-strict-aliasing:

cpu/74xx_7xx/config.mk:PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi - fno-strict-aliasing
cpu/arm1136/config.mk:PLATFORM_RELFLAGS += -fno-strict-aliasing -fno- common -ffixed-r8 \
cpu/arm1176/config.mk:PLATFORM_RELFLAGS += -fno-strict-aliasing -fno- common -ffixed-r8 \
cpu/arm1176/s3c64xx/config.mk:PLATFORM_RELFLAGS += -fno-strict- aliasing -fno-common -ffixed-r8 \
cpu/arm720t/config.mk:PLATFORM_RELFLAGS += -fno-strict-aliasing -fno- common -ffixed-r8 \
cpu/arm920t/config.mk:PLATFORM_RELFLAGS += -fno-strict-aliasing -fno- common -ffixed-r8 \
cpu/arm925t/config.mk:PLATFORM_RELFLAGS += -fno-strict-aliasing -fno- common -ffixed-r8 \
cpu/arm926ejs/config.mk:PLATFORM_RELFLAGS += -fno-strict-aliasing - fno-common -ffixed-r8 \
cpu/arm926ejs/davinci/config.mk:PLATFORM_RELFLAGS += -fno-strict- aliasing -fno-common -ffixed-r8 \
cpu/arm946es/config.mk:PLATFORM_RELFLAGS += -fno-strict-aliasing -fno- common -ffixed-r8 \
cpu/arm_cortexa8/config.mk:PLATFORM_RELFLAGS += -fno-strict-aliasing - fno-common -ffixed-r8 \
cpu/arm_cortexa8/omap3/config.mk:PLATFORM_RELFLAGS += -fno-strict- aliasing -fno-common -ffixed-r8 \
cpu/arm_intcm/config.mk:PLATFORM_RELFLAGS += -fno-strict-aliasing - fno-common -ffixed-r8 \
cpu/ixp/config.mk:PLATFORM_RELFLAGS += -fno-strict-aliasing -fno- common -ffixed-r8 \
cpu/lh7a40x/config.mk:PLATFORM_RELFLAGS += -fno-strict-aliasing -fno- common -ffixed-r8 \
cpu/mpc824x/config.mk:PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi - fno-strict-aliasing
cpu/mpc8xx/config.mk:PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi - fno-strict-aliasing
cpu/ppc4xx/config.mk:PLATFORM_RELFLAGS += -fPIC -ffixed-r14 -meabi - fno-strict-aliasing
cpu/pxa/config.mk:PLATFORM_RELFLAGS += -fno-strict-aliasing -fno- common -ffixed-r8 \
cpu/s3c44b0/config.mk:PLATFORM_RELFLAGS += -fno-strict-aliasing -fno- common -ffixed-r8 \
cpu/sa1100/config.mk:PLATFORM_RELFLAGS += -fno-strict-aliasing -fno- common -ffixed-r8 \

- k

#12 lore raw

PATCH 1/1 ahci: Fix gcc 4.4 compiler warning

In reply to Kumar Gala

Dear Kumar Gala,

Quoted 7 lines · In message <[email protected]> you…

ahci.c: In function 'ata_scsiop_read_capacity10':
ahci.c:616: warning: dereferencing type-punned pointer will break strict-aliasing rules

---
 drivers/block/ahci.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
How come everyone's going so slow if it's called rush hour?
#13 lore raw

PATCH 1/1 drivers/bios_emulator: Fix gcc 4.4 compiler warning

In reply to Kumar Gala

Dear Kumar Gala,

Quoted 7 lines · In message <[email protected]> you…

biosemu.c: In function 'BE_setVGA':
biosemu.c:147: warning: dereferencing type-punned pointer will break strict-aliasing rules

---
 drivers/bios_emulator/biosemu.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
An Elephant is a mouse with an Operating System.              - Knuth