linux-yocto/tools/testing/selftests
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
..
alsa kselftest/alsa - mixer-test: Fix the print format specifier warning 2024-01-25 15:27:38 -08:00
amd-pstate
arm64 kselftest/arm64: Specify SVE data when testing VL set in sve-ptrace 2025-08-28 16:25:56 +02:00
bpf minmax: add in_range() macro 2025-10-02 13:40:41 +02:00
breakpoints selftests: breakpoints: use remaining time to check if suspend succeed 2024-10-17 15:21:49 +02:00
capabilities
cgroup selftests: cgroup: fix unexpected failure on test_memcg_low 2023-07-19 16:21:08 +02:00
clone3 selftests: clone3: Fix incorrect kernel headers search path 2023-03-10 09:34:16 +01:00
core fix bitmap corruption on close_range() with CLOSE_RANGE_UNSHARE 2024-08-29 17:30:15 +02:00
cpu-hotplug
cpufreq
damon
dma
dmabuf-heaps kselftests: dmabuf-heaps: Ensure the driver name is null-terminated 2024-09-12 11:10:24 +02:00
drivers net: netdevsim: try to close UDP port harness races 2025-02-21 13:49:22 +01:00
efivarfs selftests/efivarfs: create-read: fix a resource leak 2023-11-28 17:06:58 +00:00
exec binfmt_elf: Honor PT_LOAD alignment for static PIE 2025-05-22 14:09:59 +02:00
filesystems selftests/binderfs: use the Makefile's rules, not Make's implicit rules 2024-06-12 11:03:15 +02:00
firmware
fpu
ftrace selftests: tracing: Use mutex_unlock for testing glob filter 2025-08-28 16:25:53 +02:00
futex selftests/futex: Define SYS_futex on 32-bit architectures with 64-bit time_t 2025-08-28 16:25:52 +02:00
gpio selftests: gpio: gpio-sim: Fix missing chip disablements 2025-02-21 13:50:00 +01:00
ia64
intel_pstate
ipc selftests: ipc: Fix incorrect kernel headers search path 2023-03-10 09:34:18 +01:00
ir
kcmp selftests/kcmp: remove unused open mode 2024-06-12 11:03:31 +02:00
kexec
kmod
kselftest kselftest/runner.sh: Propagate SIGTERM to runner child 2023-09-19 12:28:08 +02:00
kvm KVM: selftests: Add test for uaccesses to non-existent vgic-v2 CPUIF 2024-06-12 11:03:01 +02:00
landlock landlock: Add the errata interface 2025-04-25 10:44:02 +02:00
lib
livepatch
lkdtm selftests/lkdtm: Disable CONFIG_UBSAN_TRAP in test config 2023-11-28 17:06:54 +00:00
locking
media_tests selftests: media_tests: Fix incorrect kernel headers search path 2023-03-10 09:34:16 +01:00
membarrier selftests: membarrier: Fix incorrect kernel headers search path 2023-03-10 09:34:16 +01:00
memfd selftests/memfd: add test for mapping write-sealed memfd read-only 2025-08-28 16:26:12 +02:00
memory-hotplug
mincore selftests/mincore: Allow read-ahead pages to reach the end of the file 2025-05-02 07:47:06 +02:00
mount
mount_setattr selftests/mount_setattr: Fix failures on 64K PAGE_SIZE kernels 2024-12-14 19:53:48 +01:00
move_mount_set_group selftests: move_mount_set_group: Fix incorrect kernel headers search path 2023-03-10 09:34:17 +01:00
mqueue selftests/mqueue: Set timeout to 180 seconds 2024-04-03 15:19:26 +02:00
nci
net selftests: fib_nexthops: Fix creation of non-FDB nexthops 2025-10-02 13:40:39 +02:00
netfilter selftests: netfilter: Fix nft_audit.sh for newer nft binaries 2024-10-17 15:21:31 +02:00
nolibc selftests/nolibc: avoid passing NULL to printf("%s") 2024-10-17 15:21:41 +02:00
nsfs
ntb
openat2 selftests/openat2: Fix build warnings on ppc64 2024-07-25 09:49:10 +02:00
perf_events selftests/perf_events: Add a mmap() correctness test 2025-08-15 12:05:11 +02:00
pid_namespace selftests: pid_namespace: Fix incorrect kernel headers search path 2023-03-10 09:34:16 +01:00
pidfd selftests/pidfd: Fix ksft print formats 2023-11-20 11:52:03 +01:00
powerpc selftests/powerpc: Fix argument order to timer_sub() 2025-02-21 13:48:53 +01:00
prctl
proc proc: fix PIE proc-empty-vm, proc-pid-vm tests 2023-01-24 07:24:33 +01:00
pstore
ptp selftests/ptp: Fix timestamp printf format for PTP_SYS_OFFSET 2023-06-21 16:01:02 +02:00
ptrace
rcutorture clocksource: Scale the watchdog read retries automatically 2024-08-14 13:52:57 +02:00
resctrl selftests/resctrl: Protect against array overrun during iMC config parsing 2024-12-14 19:53:23 +01:00
rlimits
rseq selftests/rseq: Fix build with undefined __weak 2023-08-16 18:27:25 +02:00
rtc
safesetid
sched selftests: sched: Fix incorrect kernel headers search path 2023-03-10 09:34:15 +01:00
seccomp minmax: make generic MIN() and MAX() macros available everywhere 2025-10-02 13:40:43 +02:00
sgx selftests/sgx: Fix linker script asserts 2024-02-05 20:12:58 +00:00
sigaltstack selftests/sigaltstack: Fix ppc64 GCC build 2024-08-03 08:49:43 +02:00
size
sparc64
splice
static_keys
sync selftests: sync: Fix incorrect kernel headers search path 2023-03-10 09:34:17 +01:00
syscall_user_dispatch selftests: Fix errno checking in syscall_user_dispatch test 2025-08-15 12:04:53 +02:00
sysctl
tc-testing selftests: tc-testing: reduce rshift value 2025-01-23 17:17:12 +01:00
timens
timers selftests: timers: clocksource-switch: Adapt progress to kselftest framework 2025-02-21 13:49:04 +01:00
tmpfs
tpm2
ublk selftests: ublk: fix test_stripe_04 2025-05-02 07:47:05 +02:00
uevent
user
user_events tracing/user_events: Ensure write index cannot be negative 2023-05-11 23:03:32 +09:00
vDSO powerpc/vdso: Flag VDSO64 entry points as functions 2024-12-14 19:53:35 +01:00
vm minmax: make generic MIN() and MAX() macros available everywhere 2025-10-02 13:40:43 +02:00
watchdog selftests/watchdog-test: Fix system accidentally reset after watchdog-test 2024-12-14 19:53:08 +01:00
wireguard wireguard: selftests: load nf_conntrack if not present 2024-12-14 19:53:34 +01:00
x86 selftests/x86: Add a test to detect infinite SIGTRAP handler loop 2025-06-27 11:07:37 +01:00
zram
.gitignore
gen_kselftest_tar.sh
kselftest_deps.sh selftests: fix dependency checker script 2023-10-06 14:56:52 +02:00
kselftest_harness.h selftests: harness: fix printing of mismatch values in __EXPECT() 2025-02-21 13:49:04 +01:00
kselftest_install.sh
kselftest_module.h
kselftest.h
lib.mk selftests: default to host arch for LLVM builds 2024-06-12 11:03:16 +02:00
Makefile selftests: use printf instead of echo -ne 2023-03-10 09:33:27 +01:00
run_kselftest.sh