openbmc.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Julia Lawall <julia.lawall@lip6.fr>
Cc: Guenter Roeck <linux@roeck-us.net>,
	Tomer Maimon <tmaimon77@gmail.com>,
	 cocci <cocci@systeme.lip6.fr>,
	robh+dt@kernel.org, mark.rutland@arm.com, jdelvare@suse.com,
	 avifishman70@gmail.com, yuenn@google.com,
	brendanhiggins@google.com,  venture@google.com, joel@jms.id.au,
	devicetree@vger.kernel.org,  linux-kernel@vger.kernel.org,
	linux-hwmon@vger.kernel.org,  openbmc@lists.ozlabs.org
Subject: Re: [PATCH v2 2/2] hwmon: npcm750: add NPCM7xx PWM and Fan driver
Date: Thu, 21 Jun 2018 07:48:38 -0700	[thread overview]
Message-ID: <8f9c37fd13abe2596521afb5d2779f644c214a93.camel@perches.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1806211515060.3774@hadrien>

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.

  reply	other threads:[~2018-06-21 14:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-19 10:53 [PATCH v2 0/2] hwmon: Add NPCM7xx PWM and Fan driver support Tomer Maimon
2018-06-19 10:53 ` [PATCH v2 1/2] dt-binding: hwmon: Add NPCM7xx PWM and Fan controller documentation Tomer Maimon
2018-06-19 10:53 ` [PATCH v2 2/2] hwmon: npcm750: add NPCM7xx PWM and Fan driver Tomer Maimon
2018-06-19 14:31   ` kbuild test robot
2018-06-19 19:43   ` kbuild test robot
2018-06-20 16:48   ` Guenter Roeck
2018-06-20 18:25     ` Joe Perches
2018-06-20 19:38       ` Guenter Roeck
2018-06-21 13:17       ` Julia Lawall
2018-06-21 14:48         ` Joe Perches [this message]
2018-06-21 13:46   ` Guenter Roeck

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=8f9c37fd13abe2596521afb5d2779f644c214a93.camel@perches.com \
    --to=joe@perches.com \
    --cc=avifishman70@gmail.com \
    --cc=brendanhiggins@google.com \
    --cc=cocci@systeme.lip6.fr \
    --cc=devicetree@vger.kernel.org \
    --cc=jdelvare@suse.com \
    --cc=joel@jms.id.au \
    --cc=julia.lawall@lip6.fr \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=mark.rutland@arm.com \
    --cc=openbmc@lists.ozlabs.org \
    --cc=robh+dt@kernel.org \
    --cc=tmaimon77@gmail.com \
    --cc=venture@google.com \
    --cc=yuenn@google.com \
    /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;
as well as URLs for NNTP newsgroup(s).