Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Feb 2009 22:04:02 +1100
From:      Andrew Reilly <andrew-freebsd@areilly.bpc-users.org>
To:        "M. Warner Losh" <imp@bsdimp.com>
Cc:        mips@FreeBSD.org, tinderbox@FreeBSD.org, current@FreeBSD.org
Subject:   Re: [head tinderbox] failure on mips/mips
Message-ID:  <20090218110402.GA13040@duncan.reilly.home>
In-Reply-To: <20090217.222152.-109416210.imp@bsdimp.com>
References:  <20090218023328.227617302F@freebsd-current.sentex.ca> <20090217.203647.-1518647466.imp@bsdimp.com> <20090217.222152.-109416210.imp@bsdimp.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Feb 17, 2009 at 10:21:52PM -0700, M. Warner Losh wrote:
> In message: <20090217.203647.-1518647466.imp@bsdimp.com>
>             "M. Warner Losh" <imp@bsdimp.com> writes:
> : In message: <20090218023328.227617302F@freebsd-current.sentex.ca>
> :             FreeBSD Tinderbox <tinderbox@freebsd.org> writes:
> : : /src/usr.sbin/bsnmpd/modules/snmp_mibII/../../../../contrib/bsnmp/snmp_mibII/mibII.c:1016: warning: cast increases required alignment of target type
> The first one is:
> 
> 	  case RTM_IFINFO:
> 		ifm = (struct if_msghdr *)rtm;
> 		mib_extract_addrs(ifm->ifm_addrs, (u_char *)(ifm + 1), addrs);
> 		if ((ifp = mib_find_if_sys(ifm->ifm_index)) == NULL)
> 			break;
> 
> rtm is of type struct rt_msghdr.  This has an alignment requirement of
> 4 on mips, at least on 32-bit mips (the biggest data element is a
> u_long).  struct if_msghdr has an alignment requirement of 8, because
> time_t is int64_t on MIPS, which is 8-bytes in size.

If the memory that rtm can be pointing to can be either a struct
rt_msghdr or a struct if_msghdr, then shouldn't it really be
pointing to a union of those two, and then the alignment will
sort itself out?  (As far as I know, that's the only way that
C99 will guarantee that the right thing happens anyway,
otherwise strict aliasing analysis would allow much worse
badness to happen, potentially.)

Not looked at the code myself.  Perhaps there's a reason why
that would be unworkable.

Cheers,

Andrew



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090218110402.GA13040>