Skip to contentSkip to conversation

selftests/bpf: include limits.h needed for PATH_MAX directly

PATCH Applied Eduard Zingerman 3 participants 3 messages Jun 18, 2025

Subsystems (3)
lore
Share & tools
lore

Eduard Zingerman

author maintainer
#0 lore raw

PATCH 1/1 selftests/bpf: include limits.h needed for PATH_MAX directly

Constant PATH_MAX is used in function unpriv_helpers.c:open_config(). This constant is provided by include file <limits.h>.
The dependency was added by commit [1], which does not include <limits.h> directly, relying instead on <limits.h> being included from zlib.h -> zconf.h.
As it turns out, this is not the case for all systems, e.g. on Fedora 41 zlib 1.3.1 is used, and there <limits.h> is not included from zconf.h. Hence, there is a compilation error on Fedora 41.

[1] commit fc2915bb8bfc ("selftests/bpf: More precise cpu_mitigations state detection")

Fixes fc2915bb8bfc ("selftests/bpf: More precise cpu_mitigations state detection")
---
 tools/testing/selftests/bpf/unpriv_helpers.c | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/unpriv_helpers.c +1 -0
index 3aa9ee80a55e..f997d7ec8fd0 100644
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 
 #include <errno.h>
+#include <limits.h>
 #include <stdbool.h>
 #include <stdlib.h>
 #include <stdio.h>
Signature · 1 line
2.48.1
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Eduard Zingerman

Constant PATH_MAX is used in function unpriv_helpers.c:open_config(). This constant is provided by include file <limits.h>.
The dependency was added by commit [1], which does not include <limits.h> directly, relying instead on <limits.h> being included from zlib.h -> zconf.h.
As it turns out, this is not the case for all systems, e.g. on Fedora 41 zlib 1.3.1 is used, and there <limits.h> is not included from zconf.h. Hence, there is a compilation error on Fedora 41.

Quoted 4 lines

[1] commit fc2915bb8bfc ("selftests/bpf: More precise cpu_mitigations state detection")

Fixes fc2915bb8bfc ("selftests/bpf: More precise cpu_mitigations state detection")

Just ran across this on a ppc Fedora 42. Thanks for the fix, it works!

Quoted 16 lines
---
 tools/testing/selftests/bpf/unpriv_helpers.c | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/unpriv_helpers.c +1 -0
index 3aa9ee80a55e..f997d7ec8fd0 100644
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 
 #include <errno.h>
+#include <limits.h>
 #include <stdbool.h>
 #include <stdlib.h>
 #include <stdio.h>
#2 lore raw
In reply to Eduard Zingerman
This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:

Hello:

This patch was applied to bpf/bpf-next.git (master) by Alexei Starovoitov <[email protected]>:

Quoted 10 lines · On Wed, 18 Jun 2025 02:31:34 -0700 you wrote:

Constant PATH_MAX is used in function unpriv_helpers.c:open_config(). This constant is provided by include file <limits.h>.
The dependency was added by commit [1], which does not include <limits.h> directly, relying instead on <limits.h> being included from zlib.h -> zconf.h.
As it turns out, this is not the case for all systems, e.g. on Fedora 41 zlib 1.3.1 is used, and there <limits.h> is not included from zconf.h. Hence, there is a compilation error on Fedora 41.

[...]

Here is the summary with links:
- [bpf-next,v1] selftests/bpf: include limits.h needed for PATH_MAX directly

    https://git.kernel.org/bpf/bpf-next/c/cd7312a78f36

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html