Re: recent current kernel compile failure

From: Stefan Farfeleder <stefan_at_fafoe.narf.at>
Date: Thu, 27 Jan 2005 14:54:53 +0100
On Thu, Jan 27, 2005 at 04:49:35AM -0700, Scott Long wrote:
> Divacky Roman wrote:
> 
> >hi
> >
> >recent current with CFLAGS=-O2:
> >
> >../dev/amr/amr_pci.c
> >/usr/src/sys/modules/amr/../../dev/amr/amr_pci.c: In function 
> >`amr_setup_mbox':
> >/usr/src/sys/modules/amr/../../dev/amr/amr_pci.c:605: warning: 
> >dereferencing
> >type-punned pointer will break strict-aliasing rules
> >
> >would be nice to have this repaired
> >
> >roman
> 
> We don't support compiling with -fstrict-aliasing.  The correct solution 
> is likely to change the type of 'p' and add a bunch of casts.  Not very 
> pretty, but I guess no worse than the horribly non-informative gcc 
> message that is generated here.

This patch should be better:

Index: amr_pci.c
===================================================================
RCS file: /b/ncvs/src/sys/dev/amr/amr_pci.c,v
retrieving revision 1.27
diff -I.svn -u -r1.27 amr_pci.c
--- amr_pci.c	23 Jan 2005 23:25:41 -0000	1.27
+++ amr_pci.c	27 Jan 2005 13:51:27 -0000
_at__at_ -574,7 +574,7 _at__at_
 amr_setup_mbox(struct amr_softc *sc)
 {
     int		error;
-    u_int8_t	*p;
+    void	*p;
     
     debug_called(1);
 
_at__at_ -602,7 +602,7 _at__at_
      * Allocate the mailbox structure and permanently map it into
      * controller-visible space.
      */
-    error = bus_dmamem_alloc(sc->amr_mailbox_dmat, (void **)&p, BUS_DMA_NOWAIT,
+    error = bus_dmamem_alloc(sc->amr_mailbox_dmat, &p, BUS_DMA_NOWAIT,
 			     &sc->amr_mailbox_dmamap);
     if (error) {
 	device_printf(sc->amr_dev, "can't allocate mailbox memory\n");
_at__at_ -614,8 +614,8 _at__at_
      * Conventional mailbox is inside the mailbox64 region.
      */
     bzero(p, sizeof(struct amr_mailbox64));
-    sc->amr_mailbox64 = (struct amr_mailbox64 *)(p + 12);
-    sc->amr_mailbox = (struct amr_mailbox *)(p + 16);
+    sc->amr_mailbox64 = (struct amr_mailbox64 *)((char *)p + 12);
+    sc->amr_mailbox = (struct amr_mailbox *)((char *)p + 16);
 
     return(0);
 }

Stefan
Received on Thu Jan 27 2005 - 12:54:59 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:27 UTC