]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/bpf: Allow macros in __retval
authorViktor Malik <vmalik@redhat.com>
Thu, 26 Jun 2025 06:08:30 +0000 (08:08 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 26 Jun 2025 16:44:46 +0000 (09:44 -0700)
commita55b7d39328bc6de1131cb5496816129cab2728b
treea36239ec100f7304f12f5c462efa99323f01d6e2
parente91370550f1fe6fa3b02e8bf9762e3dc0a02fcad
selftests/bpf: Allow macros in __retval

Allow macro expansion for values passed to the `__retval` and
`__retval_unpriv` attributes. This is especially useful for testing
programs which return various error codes.

With this change, the code for parsing special literals can be made
simpler, as the literals are defined via macros. The only exception is
INT_MIN which expands to (-INT_MAX -1), which is not single number and
cannot be parsed by strtol. So, we instead use a prefixed literal
_INT_MIN in __retval and handle it separately (assign the expected
return to INT_MIN). Also, strtol cannot handle the "ll" suffix so change
the value of POINTER_VALUE from 0xcafe4all to 0xbadcafe.

Signed-off-by: Viktor Malik <vmalik@redhat.com>
Link: https://lore.kernel.org/r/a6c6b551ae0575351faa7b7a1df52f9341a5cbe8.1750917800.git.vmalik@redhat.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/progs/bpf_misc.h
tools/testing/selftests/bpf/progs/verifier_div_overflow.c
tools/testing/selftests/bpf/test_loader.c