From: Tom Rini Date: Mon, 25 Apr 2016 16:43:25 -0400 Subject: [U-Boot] [PATCH v5 2/4] net: designware: fix descriptor layout and warnings on 64-bit archs In-Reply-To: <571E80B9.6030409@denx.de> References: <1461480602-2932-1-git-send-email-b.galvani@gmail.com> <1461480602-2932-3-git-send-email-b.galvani@gmail.com> <20160425201729.GA9337@gmail.com> <571E80B9.6030409@denx.de> Message-ID: <20160425204325.GA29322@bill-the-cat> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Mon, Apr 25, 2016 at 10:40:25PM +0200, Marek Vasut wrote: > On 04/25/2016 10:32 PM, Joe Hershberger wrote: > > On Mon, Apr 25, 2016 at 3:17 PM, Beniamino Galvani wrote: > >> On Mon, Apr 25, 2016 at 01:01:10PM -0500, Joe Hershberger wrote: > >>>> - desc_p->dmamac_addr = &txbuffs[idx * CONFIG_ETH_BUFSIZE]; > >>>> - desc_p->dmamac_next = &desc_table_p[idx + 1]; > >>>> + desc_p->dmamac_addr = (ulong)&txbuffs[idx * CONFIG_ETH_BUFSIZE]; > >>>> + desc_p->dmamac_next = (ulong)&desc_table_p[idx + 1]; > >>> > >>> Why are you not casting to the type of the struct member (u32)? Won't > >>> this emit warnings on 64-bit? > >> > >> Hi, > >> > >> casting to u32 would cause a warning on arm64 ("warning: cast from > >> pointer to integer of different size [-Wpointer-to-int-cast]") because > >> the pointer is 64bit. > >> > >> The (ulong) cast is needed to convert the pointer to an arithmetic > >> type of same width, which then can be assigned to the struct > >> member. The assignment operator implicitly converts between different > >> arithmetic types without the need for explicit casts. > > > > That's the part that surprises me. I thought arithmetic assignments > > from larger to smaller types would warn. > > > > Anyway, if it's warning clean, > > I am still not a big fan of picking the right type just to silence all > possible warnings. I am worried this will bite us in the future. When that future comes we'll have lots of things to fixup and convert to a better solution. -- Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: