Go to file
Linus Torvalds 7d4fa074a2 minmax: make generic MIN() and MAX() macros available everywhere
[ Upstream commit 1a251f52cf ]

This just standardizes the use of MIN() and MAX() macros, with the very
traditional semantics.  The goal is to use these for C constant
expressions and for top-level / static initializers, and so be able to
simplify the min()/max() macros.

These macro names were used by various kernel code - they are very
traditional, after all - and all such users have been fixed up, with a
few different approaches:

 - trivial duplicated macro definitions have been removed

   Note that 'trivial' here means that it's obviously kernel code that
   already included all the major kernel headers, and thus gets the new
   generic MIN/MAX macros automatically.

 - non-trivial duplicated macro definitions are guarded with #ifndef

   This is the "yes, they define their own versions, but no, the include
   situation is not entirely obvious, and maybe they don't get the
   generic version automatically" case.

 - strange use case #1

   A couple of drivers decided that the way they want to describe their
   versioning is with

	#define MAJ 1
	#define MIN 2
	#define DRV_VERSION __stringify(MAJ) "." __stringify(MIN)

   which adds zero value and I just did my Alexander the Great
   impersonation, and rewrote that pointless Gordian knot as

	#define DRV_VERSION "1.2"

   instead.

 - strange use case #2

   A couple of drivers thought that it's a good idea to have a random
   'MIN' or 'MAX' define for a value or index into a table, rather than
   the traditional macro that takes arguments.

   These values were re-written as C enum's instead. The new
   function-line macros only expand when followed by an open
   parenthesis, and thus don't clash with enum use.

Happily, there weren't really all that many of these cases, and a lot of
users already had the pattern of using '#ifndef' guarding (or in one
case just using '#undef MIN') before defining their own private version
that does the same thing. I left such cases alone.

Cc: David Laight <David.Laight@aculab.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Eliav Farber <farbere@amazon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-10-02 13:40:43 +02:00
arch minmax: make generic MIN() and MAX() macros available everywhere 2025-10-02 13:40:43 +02:00
block block: reject invalid operation in submit_bio_noacct 2025-08-28 16:26:10 +02:00
certs sign-file,extract-cert: use pkcs11 provider for OPENSSL MAJOR >= 3 2025-04-25 10:44:04 +02:00
crypto crypto: af_alg - Disallow concurrent writes in af_alg_sendmsg 2025-09-25 10:58:55 +02:00
Documentation docs: networking: can: change bcm_msg_head frames member to support flexible array 2025-09-19 16:29:58 +02:00
drivers minmax: make generic MIN() and MAX() macros available everywhere 2025-10-02 13:40:43 +02:00
fs minmax: add in_range() macro 2025-10-02 13:40:41 +02:00
include minmax: make generic MIN() and MAX() macros available everywhere 2025-10-02 13:40:43 +02:00
init sched/isolation: Make CONFIG_CPU_ISOLATION depend on CONFIG_SMP 2025-05-02 07:47:04 +02:00
io_uring io_uring: include dying ring in task_work "should cancel" state 2025-09-25 10:58:53 +02:00
ipc ipc: fix to protect IPCS lookups using RCU 2025-06-27 11:07:30 +01:00
kernel minmax: make generic MIN() and MAX() macros available everywhere 2025-10-02 13:40:43 +02:00
lib minmax: make generic MIN() and MAX() macros available everywhere 2025-10-02 13:40:43 +02:00
LICENSES
mm minmax: make generic MIN() and MAX() macros available everywhere 2025-10-02 13:40:43 +02:00
net minmax: add in_range() macro 2025-10-02 13:40:41 +02:00
rust rust: module: place cleanup_module() in .exit.text section 2025-07-06 10:57:54 +02:00
samples ftrace/samples: Fix function size computation 2025-09-19 16:29:56 +02:00
scripts kconfig: lxdialog: fix 'space' to (de)select options 2025-08-28 16:26:02 +02:00
security apparmor: use the condition in AA_BUG_FMT even with debug disabled 2025-08-28 16:26:01 +02:00
sound ALSA: usb-audio: Add mute TLV for playback volumes on more devices 2025-10-02 13:40:36 +02:00
tools minmax: make generic MIN() and MAX() macros available everywhere 2025-10-02 13:40:43 +02:00
usr kbuild: hdrcheck: fix cross build with clang 2025-06-27 11:07:25 +01:00
virt KVM: Fix a data race on last_boosted_vcpu in kvm_vcpu_on_spin() 2024-06-27 13:46:21 +02:00
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore Remove *.orig pattern from .gitignore 2024-10-17 15:21:15 +02:00
.mailmap
.rustfmt.toml
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS sign-file,extract-cert: move common SSL helper functions to a header 2025-04-25 10:44:04 +02:00
Makefile Linux 6.1.154 2025-09-25 10:58:55 +02:00
README

Linux kernel

There are several guides for kernel developers and users. These guides can be rendered in a number of formats, like HTML and PDF. Please read Documentation/admin-guide/README.rst first.

In order to build the documentation, use make htmldocs or make pdfdocs. The formatted documentation can also be read online at:

https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory, several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the requirements for building and running the kernel, and information about the problems which may result by upgrading your kernel.