Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1702541
| From | Matthias Kaehlcke <mka@chromium.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 1/2] bitops: Avoid integer overflow warning in GENMASK_ULL |
| Date | 2017-08-03 01:00 +0200 |
| Message-ID | <uaaMq-7QI-5@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
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)))) #define GENMASK_ULL(h, l) \ - (((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h)))) + ((((~0ULL) >> (l)) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h)))) extern unsigned int __sw_hweight8(unsigned int w); extern unsigned int __sw_hweight16(unsigned int w); -- 2.14.0.rc1.383.gd1ce394fe2-goog
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH 1/2] bitops: Avoid integer overflow warning in GENMASK_ULL Matthias Kaehlcke <mka@chromium.org> - 2017-08-03 01:00 +0200
[PATCH 2/2] arm64: Define PAGE_OFFSET using GENMASK_ULL Matthias Kaehlcke <mka@chromium.org> - 2017-08-03 01:00 +0200
Re: [PATCH 2/2] arm64: Define PAGE_OFFSET using GENMASK_ULL Nick Desaulniers <ndesaulniers@google.com> - 2017-08-03 01:20 +0200
Re: [PATCH 2/2] arm64: Define PAGE_OFFSET using GENMASK_ULL Matthias Kaehlcke <mka@chromium.org> - 2017-08-03 01:50 +0200
Re: [PATCH 2/2] arm64: Define PAGE_OFFSET using GENMASK_ULL Nick Desaulniers <ndesaulniers@google.com> - 2017-08-03 01:20 +0200
Re: [PATCH 1/2] bitops: Avoid integer overflow warning in GENMASK_ULL Matthias Kaehlcke <mka@chromium.org> - 2017-08-03 19:10 +0200
csiph-web