Hello,

Add build time validity checks of GENMASK (and GENMASK_ULL) inputs.
The main differences from v3:

- Patch v3 1/3 was merged into Linus tree through the x86 tree and is
  not part of this series any longer.
- Disable the input check for GCC < 4.9 due to a gcc bug.

Joe Perches sent a patch series to fix existing misuses, currently there
are two remaining such misuses (which patches pending) left in Linus
tree. However, the remaining two cases are in unused macros and will not
break any builds until someone tries to use them. There was also an
arm-specific misuse which have also been fixed since v2 of this patchset
was merged to linux-next. When v3 of this patchset was included in
linux-next, there were not additional build failures or warnings
(there are some failed builds due to other patches though), however
<nore...@ellerman.id.au> and Geert Uytterhoeven reported that it broke
compilation with old versions of gcc so a v4 is needed.

Changelog
Since v3
  - Patch v2 1/3 (the x86 build warning) has been merged into Linus tree
    through the x86 tree (and is therefore not part of v4).
  - Disable the GENMASK input check if GCC version < 4.9 due to a
    compiler bug [0].

[0]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19449
  
Since v2
  - Use __builtin_constant_p instead of __is_constexpr to avoid pulling
    in kernel.h (that include was missing in v2, so the header was no
    longer builable standalone
  - add cast to BUILD_BUG_ON_ZERO to make the type int
  - Remove unnecessary casts due to the above
  - Drop patch that renamed macro arguments

Since v1
  - Add comment about why inputs are not checked when used in asm file
  - Use UL(0) instead of 0
  - Extract mask creation in a separate macro to improve readability
  - Use high and low instead of h and l (part of this was extracted to a
    separate patch)
  - Updated commit message

Rikard Falkeborn (2):
  linux/build_bug.h: Change type to int
  linux/bits.h: Add compile time sanity check of GENMASK inputs

 include/linux/bits.h      | 22 ++++++++++++++++++++--
 include/linux/build_bug.h |  4 ++--
 2 files changed, 22 insertions(+), 4 deletions(-)

-- 
2.23.0

Reply via email to