[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c81b9c01650e487785b02f6562791556@AcuMS.aculab.com>
Date: Thu, 7 Oct 2021 07:53:01 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Segher Boessenkool' <segher@...nel.crashing.org>,
Stafford Horne <shorne@...il.com>
CC: Rich Felker <dalias@...c.org>,
"Rafael J. Wysocki" <rafael@...nel.org>,
Catalin Marinas <catalin.marinas@....com>,
"x86@...nel.org" <x86@...nel.org>, Guo Ren <guoren@...nel.org>,
"H. Peter Anvin" <hpa@...or.com>,
"linux-riscv@...ts.infradead.org" <linux-riscv@...ts.infradead.org>,
"Will Deacon" <will@...nel.org>, Jonas Bonn <jonas@...thpole.se>,
Rob Herring <robh@...nel.org>,
Florian Fainelli <f.fainelli@...il.com>,
Frank Rowand <frowand.list@...il.com>,
"linux-sh@...r.kernel.org" <linux-sh@...r.kernel.org>,
Russell King <linux@...linux.org.uk>,
"linux-csky@...r.kernel.org" <linux-csky@...r.kernel.org>,
Ingo Molnar <mingo@...hat.com>,
"bcm-kernel-feedback-list@...adcom.com"
<bcm-kernel-feedback-list@...adcom.com>,
James Morse <james.morse@....com>,
"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
Albert Ou <aou@...s.berkeley.edu>, Ray Jui <rjui@...adcom.com>,
Stefan Kristiansson <stefan.kristiansson@...nalahti.fi>,
"openrisc@...ts.librecores.org" <openrisc@...ts.librecores.org>,
Borislav Petkov <bp@...en8.de>,
"Paul Walmsley" <paul.walmsley@...ive.com>,
Thomas Gleixner <tglx@...utronix.de>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
Scott Branden <sbranden@...adcom.com>,
Yoshinori Sato <ysato@...rs.osdn.me>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Palmer Dabbelt <palmer@...belt.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
"Paul Mackerras" <paulus@...ba.org>,
"linuxppc-dev@...ts.ozlabs.org" <linuxppc-dev@...ts.ozlabs.org>
Subject: RE: [PATCH 06/12] openrisc: Use of_get_cpu_hwid()
From: Segher Boessenkool
> Sent: 06 October 2021 22:27
>
> On Thu, Oct 07, 2021 at 05:44:00AM +0900, Stafford Horne wrote:
> > You have defined of_get_cpu_hwid to return u64, will this create compiler
> > warnings when since we are storing a u64 into a u32?
> >
> > It seems only if we make with W=3.
>
> Yes. This is done by -Wconversion, "Warn for implicit conversions that
> may alter a value."
>
> > I thought we usually warned on this.
The microsoft compiler does - best to turn all those warnings off.
> This warning is not in -Wall or -Wextra either, it suffers too much from
> false positives. It is very natural to just ignore the high bits of
> modulo types (which is what "unsigned" types *are*). Or the bits that
> "fall off" on a conversion. The C standard makes this required
> behaviour, it is useful, and it is the only convenient way of getting
> this!
I've also seen a compiler convert:
struct->char_member = (char)(int_val & 0xff);
into:
reg = int_val;
reg &= 0xff; // for the & 0xff
reg &= 0xff; // for the cast
struct->char_member = low_8bits(reg);
You really don't want the extra noise.
I'll bet that (char)int_val is actually an arithmetic expression.
So its type will be 'int'.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists