From: Matthias Kaehlcke <mka@chromium.org>
To: Mason <slash.tmp@free.fr>
Cc: Bjorn Helgaas <helgaas@kernel.org>,
linux-pci <linux-pci@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Grant Grundler <grundler@chromium.org>,
Greg Hackmann <ghackmann@google.com>,
Michael Davidson <md@google.com>
Subject: Re: [PATCH] PCI: Add cast when assigning PCI_ROM_ADDRESS_MASK to a 32-bit variable
Date: Tue, 11 Apr 2017 10:23:07 -0700 [thread overview]
Message-ID: <20170411172307.GC28657@google.com> (raw)
In-Reply-To: <6111642d-9f1d-f8bf-5920-82f4eb427cff@free.fr>
El Tue, Apr 11, 2017 at 12:08:38PM +0200 Mason ha dit:
> On 11/04/2017 03:24, Bjorn Helgaas wrote:
>
> > On Mon, Apr 10, 2017 at 03:24:57PM -0700, Matthias Kaehlcke wrote:
> >
> >> This fixes a clang warning about "implicit conversion from 'unsigned
> >> long' to 'u32'"
> >>
> >> Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> >> ---
> >> drivers/pci/probe.c | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> >> index dfc9a2794141..148e80d5caf1 100644
> >> --- a/drivers/pci/probe.c
> >> +++ b/drivers/pci/probe.c
> >> @@ -180,7 +180,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
> >> u16 orig_cmd;
> >> struct pci_bus_region region, inverted_region;
> >>
> >> - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
> >> + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
> >
> > Can we put the cast in the PCI_ROM_ADDRESS_MASK #define so we don't have to
> > repeat it in all the uses?
>
> Fixing these "implicit conversion" warnings, especially for
> unsigned types, is a slippery slope. (The behavior of the
> conversion is well-defined.)
>
> How about changing the type of PCI_ROM_ADDRESS_MASK instead?
> It's defined as ~0x7ffUL but it's only used in the context
> of u32.
>
> So make it an unsigned int:
> #define PCI_ROM_ADDRESS_MASK (~0x7ffU)
>
> AFAIU, unsigned int is 32 bits on all platforms supported
> by Linux.
I considered this initially, but wasn't sure if the unsigned long
mask might be needed in some cases. From the comments I interpret that
there should be no problems with using a 32 bit mask everywhere.
I'll send out an updated patch shortly.
Thanks
Matthias
next prev parent reply other threads:[~2017-04-11 17:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-10 22:24 [PATCH] PCI: Add cast when assigning PCI_ROM_ADDRESS_MASK to a 32-bit variable Matthias Kaehlcke
2017-04-11 1:24 ` Bjorn Helgaas
2017-04-11 10:08 ` Mason
2017-04-11 17:23 ` Matthias Kaehlcke [this message]
2017-04-11 17:28 ` Mason
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=20170411172307.GC28657@google.com \
--to=mka@chromium.org \
--cc=ghackmann@google.com \
--cc=grundler@chromium.org \
--cc=helgaas@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=md@google.com \
--cc=slash.tmp@free.fr \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.