public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Matthias Kaehlcke <mka@chromium.org>
To: Yury Norov <ynorov@caviumnetworks.com>
Cc: zijun_hu <zijun_hu@htc.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Laura Abbott <labbott@redhat.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	linux-kernel@vger.kernel.org,
	Greg Hackmann <ghackmann@google.com>,
	Doug Anderson <dianders@chromium.org>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 1/2] bitops: Avoid integer overflow warning in GENMASK_ULL
Date: Thu, 3 Aug 2017 10:03:55 -0700	[thread overview]
Message-ID: <20170803170355.GJ84665@google.com> (raw)
In-Reply-To: <20170803132456.mwrt6yspkbqxcffw@yury-thinkpad>

El Thu, Aug 03, 2017 at 04:24:56PM +0300 Yury Norov ha dit:

> On Wed, Aug 02, 2017 at 03:51:58PM -0700, Matthias Kaehlcke wrote:
> > GENMASK_ULL performs a left-shift of (~0ULL), which technically
> > results in an integer overflow. clang raises a warning about
> > this if the overflow occurs in a preprocessor expression. To
> > avoid the overflow first perform a right-shift to clear the
> > bits that are shifted out.
> > 
> > Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
> > ---
> >  include/linux/bitops.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/include/linux/bitops.h b/include/linux/bitops.h
> > index a83c822c35c2..21dfe63001e3 100644
> > --- a/include/linux/bitops.h
> > +++ b/include/linux/bitops.h
> > @@ -22,7 +22,7 @@
> >  	(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
> 
> Once you touche GENMASK_ULL, why not to fix also GENMASK.

Will do, thanks.

Even though GENMASK_ULL can't be used (as is) to define the arm64
PAGE_OFFSET as initially intended it seems the change is still
worthwhile since there are a few other preprocessor expressions using
GENMASK_ULL.

      reply	other threads:[~2017-08-03 17:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-02 22:51 [PATCH 1/2] bitops: Avoid integer overflow warning in GENMASK_ULL Matthias Kaehlcke
2017-08-02 22:51 ` [PATCH 2/2] arm64: Define PAGE_OFFSET using GENMASK_ULL Matthias Kaehlcke
2017-08-02 23:13   ` Nick Desaulniers
2017-08-02 23:19     ` Nick Desaulniers
2017-08-02 23:44       ` Matthias Kaehlcke
2017-08-03 13:20   ` Yury Norov
2017-08-03 17:11     ` [PATCH] arm64: avoid overflow in VA_START and PAGE_OFFSET Nick Desaulniers
2017-08-03 17:20       ` Ard Biesheuvel
2017-08-03 17:53         ` Nick Desaulniers
2017-08-03 18:03           ` [PATCH v2] " Nick Desaulniers
2017-08-04  2:26   ` [PATCH 2/2] arm64: Define PAGE_OFFSET using GENMASK_ULL kbuild test robot
2017-08-03 13:24 ` [PATCH 1/2] bitops: Avoid integer overflow warning in GENMASK_ULL Yury Norov
2017-08-03 17:03   ` Matthias Kaehlcke [this message]

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=20170803170355.GJ84665@google.com \
    --to=mka@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=catalin.marinas@arm.com \
    --cc=dianders@chromium.org \
    --cc=ghackmann@google.com \
    --cc=labbott@redhat.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=ndesaulniers@google.com \
    --cc=will.deacon@arm.com \
    --cc=ynorov@caviumnetworks.com \
    --cc=zijun_hu@htc.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