Skip to content

minmax.h: Cleanups and minor optimisations

David Laight intel-gfx intel-xe linux-mm lkml llvm oe-kbuild-all 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest7 patches 23 repliesIn review 6 of 7 applied

Patches in v1 6 of 7 applied

#Subject and filesSizeRepliesApplied
1/7minmax.h: Add whitespace around operators and after commasinclude/linux/minmax.h+17 -170 replies
2/7minmax.h: Update some commentsinclude/linux/minmax.h+24 -290 repliesApplied
3/7minmax.h: Reduce the #define expansion of min(), max() and clamp()include/linux/minmax.h+12 -120 repliesApplied
4/7minmax.h: Use BUILD_BUG_ON_MSG() for the lo < hi test in clamp()include/linux/minmax.h+1 -222 repliesApplied
5/7minmax.h: Move all the clamp() definitions after the min/max() onesinclude/linux/minmax.h+51 -580 repliesApplied
6/7minmax.h: Simplify the variants of clamp()include/linux/minmax.h+12 -121 replyApplied
7/7minmax.h: Remove some #defines that are only expanded onceinclude/linux/minmax.h+6 -80 repliesApplied

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH next 0/7] minmax.h: Cleanups and minor optimisations

Some tidyups and minor changes to minmax.h.

Patches 1, 2 and 5 have no functional changes.
Patch 3 changes the statically_true() tests in __types_ok() to use the
local 'unique' variables rather than the caller supplied expressions. This will reduce the line length of the preprocessor output.
Patch 4 uses statically_true() for clamp's (lo) < (hi) check. Patch 6 passes '__auto_type' as the 'fixed type' to reduce the number
of variants.
Patch 7 removes a level of indirection from __sign_use() and
__is_nonneg().

David Laight (7):
1) Add whitespace around operators and after commas
2) Update some comments
3) Reduce the #define expansion of min(), max() and clamp()
4) Use BUILD_BUG_ON_MSG() for the lo < hi test in clamp()
5) Move all the clamp() definitions after the min/max() ones.
6) Simplify the variants of clamp()
7) Remove some #defines that are only expanded once

 include/linux/minmax.h | 205 +++++++++++++++++++----------------------
 1 file changed, 95 insertions(+), 110 deletions(-)
Signature · 5 lines
2.17.1

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)