public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v5 2/4] net: designware: fix descriptor layout and warnings on 64-bit archs
Date: Mon, 25 Apr 2016 22:40:25 +0200	[thread overview]
Message-ID: <571E80B9.6030409@denx.de> (raw)
In-Reply-To: <CANr=Z=ZyYcddquTuy2yBF=mojFOYNMKneMZJOmWN-NOBCzFdHw@mail.gmail.com>

On 04/25/2016 10:32 PM, Joe Hershberger wrote:
> On Mon, Apr 25, 2016 at 3:17 PM, Beniamino Galvani <b.galvani@gmail.com> 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.

> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
> 


-- 
Best regards,
Marek Vasut

  reply	other threads:[~2016-04-25 20:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-24  6:49 [U-Boot] [PATCH v5 0/4] Amlogic Meson GXBaby and ODROID-C2 support Beniamino Galvani
2016-04-24  6:49 ` [U-Boot] [PATCH v5 1/4] arm: implement generic PSCI reset call for armv8 Beniamino Galvani
2016-04-24  6:50 ` [U-Boot] [PATCH v5 2/4] net: designware: fix descriptor layout and warnings on 64-bit archs Beniamino Galvani
2016-04-25 18:01   ` Joe Hershberger
2016-04-25 20:17     ` Beniamino Galvani
2016-04-25 20:32       ` Joe Hershberger
2016-04-25 20:40         ` Marek Vasut [this message]
2016-04-25 20:43           ` Tom Rini
2016-04-24  6:50 ` [U-Boot] [PATCH v5 3/4] arm: add initial support for Amlogic Meson and ODROID-C2 Beniamino Galvani
2016-04-25 20:53   ` Tom Rini
2016-04-27 10:58     ` Beniamino Galvani
2016-05-01 18:56   ` Simon Glass
2016-05-01 18:58     ` Tom Rini
2016-05-08  6:35     ` Beniamino Galvani
2016-04-24  6:50 ` [U-Boot] [PATCH v5 4/4] arm: meson: implement calls to secure monitor Beniamino Galvani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=571E80B9.6030409@denx.de \
    --to=marex@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox