[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <8f9c37fd13abe2596521afb5d2779f644c214a93.camel@perches.com>
Date: Thu, 21 Jun 2018 07:48:38 -0700
From: Joe Perches <joe@...ches.com>
To: Julia Lawall <julia.lawall@...6.fr>
Cc: Guenter Roeck <linux@...ck-us.net>,
Tomer Maimon <tmaimon77@...il.com>,
cocci <cocci@...teme.lip6.fr>, robh+dt@...nel.org,
mark.rutland@....com, jdelvare@...e.com, avifishman70@...il.com,
yuenn@...gle.com, brendanhiggins@...gle.com, venture@...gle.com,
joel@....id.au, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-hwmon@...r.kernel.org,
openbmc@...ts.ozlabs.org
Subject: Re: [PATCH v2 2/2] hwmon: npcm750: add NPCM7xx PWM and Fan driver
On Thu, 2018-06-21 at 15:17 +0200, Julia Lawall wrote:
> On Wed, 20 Jun 2018, Joe Perches wrote:
> > Also, spatch (1.0.4) seems to have a defect for this
> > when the type is used in operations that change a
> > smaller type to int or unsigned int.
> >
> > i.e.: (offset is u16, but offset * 2 is int)
>
> Ah. The rule is that the result type is always the larger one?
Yes, but not quite, no.
The c90 rules are called "integer promotions" and are
detailed in section 6.3 Conversions
Basically, if any type is smaller than int, all operations
are done as int if possible, or unsigned int if necessary.
If any type is larger than int, then the larger type is used.
If you don't have the c90 standard, this one is close enough.
http://c0x.coding-guidelines.com/6.3.html
(use the next button several times to read the whole section)
Also, section 6.5 details "expressions" where the operands
of things like bit operations use integer promotions.
> Unfortunately, Coccinelle doesn't know the size of any type. I could add
> some special cases, but that may be more confusing than helpful.
Maybe, but when I saw the suggested removal, I was surprised.
Powered by blists - more mailing lists