linux/tools
Wake Liu 19b8a76cd9 kselftest/harness: Use helper to avoid zero-size memset warning
When building kselftests with a toolchain that enables source
fortification (e.g., Android's build environment, which uses
-D_FORTIFY_SOURCE=3), a build failure occurs in tests that use an
empty FIXTURE().

The root cause is that an empty fixture struct results in
`sizeof(self_private)` evaluating to 0. The compiler's fortification
checks then detect the `memset()` call with a compile-time constant size
of 0, issuing a `-Wuser-defined-warnings` which is promoted to an error
by `-Werror`.

An initial attempt to guard the call with `if (sizeof(self_private) > 0)`
was insufficient. The compiler's static analysis is aggressive enough
to flag the `memset(..., 0)` pattern before evaluating the conditional,
thus still triggering the error.

To resolve this robustly, this change introduces a `static inline`
helper function, `__kselftest_memset_safe()`. This function wraps the
size check and the `memset()` call. By replacing the direct `memset()`
in the `__TEST_F_IMPL` macro with a call to this helper, we create an
abstraction boundary. This prevents the compiler's static analyzer from
"seeing" the problematic pattern at the macro expansion site, resolving
the build failure.

Build Context:
Compiler: Android (14488419, +pgo, +bolt, +lto, +mlgo, based on r584948) clang version 22.0.0 (https://android.googlesource.com/toolchain/llvm-project 2d65e4108033380e6fe8e08b1f1826cd2bfb0c99)
Relevant Options: -O2 -Wall -Werror -D_FORTIFY_SOURCE=3 -target i686-linux-android10000

Test: m kselftest_futex_futex_requeue_pi

Removed Gerrit Change-Id
Shuah Khan <skhan@linuxfoundation.org>

Link: https://lore.kernel.org/r/20251224084120.249417-1-wakel@google.com
Signed-off-by: Wake Liu <wakel@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
2025-12-31 13:27:36 -07:00
..
accounting tools/delaytop: improve error handling for missing PSI support 2025-09-13 17:32:56 -07:00
arch [GIT PULL] perf tools changes for v6.19 2025-12-07 07:07:02 -08:00
bootconfig
bpf bpf: Remove runqslower tool 2025-11-28 15:20:16 -08:00
build [GIT PULL] perf tools changes for v6.19 2025-12-07 07:07:02 -08:00
certs
cgroup
counter
crypto
debugging
dma dma-mapping updates for Linux 6.19: 2025-12-06 09:25:05 -08:00
docs docs: makefile: move rustdoc check to the build wrapper 2025-11-29 08:42:53 -07:00
firewire
firmware
gpio tools: gpio: remove the include directory on make clean 2025-09-04 16:29:28 +02:00
hv
iio iio: add power and energy measurement modifiers 2025-09-13 13:47:19 +01:00
include hyperv-next for v6.19 2025-12-09 06:10:17 +09:00
kvm/kvm_stat
laptop
leds
lib [GIT PULL] perf tools changes for v6.19 2025-12-07 07:07:02 -08:00
memory-model
mm tools/mm/page_owner_sort: add help option support 2025-11-16 17:28:06 -08:00
net NFSD 6.19 Release Notes 2025-12-06 10:57:02 -08:00
objtool objtool: Add more robust signal error handling, detect and warn about stack overflows 2025-12-03 19:42:37 +01:00
pcmcia
perf [GIT PULL] perf tools changes for v6.19 2025-12-07 07:07:02 -08:00
power platform-drivers-x86 for v6.19-1 2025-12-10 06:38:17 +09:00
rcu
sched
sched_ext sched_ext: tools: Removing duplicate targets during non-cross compilation 2025-11-20 07:00:27 -10:00
scripts
sound
spi
testing kselftest/harness: Use helper to avoid zero-size memset warning 2025-12-31 13:27:36 -07:00
thermal tools/thermal/thermal-engine: Fix format string bug in thermal-engine 2025-11-25 11:00:28 +01:00
time
tracing rtla updaets for v6.19: 2025-12-05 09:34:01 -08:00
usb tools/usb/usbip: fix spelling mistakes in usbipd.c 2025-09-06 15:22:14 +02:00
verification
virtio tools/virtio: replace "__auto_type" with "auto" 2025-12-08 15:32:15 -08:00
wmi
workqueue
writeback
Makefile tools/dma: move dma_map_benchmark from selftests to tools/dma 2025-10-29 09:41:40 +01:00