Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kunit: test-bug.h: include `stddef.h` for `NULL`

The header uses `NULL` in both `CONFIG_KUNIT=y` and `=n` cases,
but does not include it explicitly.

When `CONFIG_KUNIT=y`, the header is already getting included via
the other headers, so it is not a problem for users.

However, when `CONFIG_KUNIT=n`, it is not, and thus a user could hit
a build error when including `kunit/test-bug.h`, like we are doing
later in this series [1].

Thus include `linux/stddef.h`, and do so outside the `#if`, since it
is used in both cases.

Reported-by: Boqun Feng <boqun.feng@gmail.com>
Closes: https://lore.kernel.org/rust-for-linux/ZJ8cNUW3oR2p+gL1@boqun-archlinux/ [1]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Miguel Ojeda and committed by
Shuah Khan
df3cb7ac 1b0975ee

+2
+2
include/kunit/test-bug.h
··· 9 9 #ifndef _KUNIT_TEST_BUG_H 10 10 #define _KUNIT_TEST_BUG_H 11 11 12 + #include <linux/stddef.h> /* for NULL */ 13 + 12 14 #if IS_ENABLED(CONFIG_KUNIT) 13 15 14 16 #include <linux/jump_label.h> /* For static branch */