Skip to contentSkip to conversation

libbpf: fix use #ifdef instead of #if to avoid compiler warning

PATCH Applied Andrii Nakryiko 2 participants 2 messages Apr 7, 2022

Subsystems (2)
lore
Share & tools
lore

Andrii Nakryiko

author maintainer
#0 lore raw

PATCH 1/1 libbpf: fix use #ifdef instead of #if to avoid compiler warning

As reported by Naresh:

perf build errors on i386 [1] on Linux next-20220407 [2]

usdt.c:1181:5: error: "__x86_64__" is not defined, evaluates to 0 [-Werror=undef]
1181 | #if __x86_64__

        |     ^~~~~~~~~~
  usdt.c:1196:5: error: "__x86_64__" is not defined, evaluates to 0
  [-Werror=undef]
   1196 | #if __x86_64__
        |     ^~~~~~~~~~

cc1: all warnings being treated as errors

Use #ifdef instead of #if to avoid this.

Cc Stephen Rothwell <[email protected]>
Fixes 4c59e584d158 ("libbpf: Add x86-specific USDT arg spec parsing logic")
---
 tools/lib/bpf/usdt.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/lib/bpf/usdt.c +2 -2
index bb1e88613343..b699e720136a 100644
@@ -1178,7 +1178,7 @@ static int calc_pt_regs_off(const char *reg_name)
 		const char *names[4];
 		size_t pt_regs_off;
 	} reg_map[] = {
-#if __x86_64__
+#ifdef __x86_64__
 #define reg_off(reg64, reg32) offsetof(struct pt_regs, reg64)
 #else
 #define reg_off(reg64, reg32) offsetof(struct pt_regs, reg32)
@@ -1193,7 +1193,7 @@ static int calc_pt_regs_off(const char *reg_name)
 		{ {"rbp", "ebp", "bp", "bpl"}, reg_off(rbp, ebp) },
 		{ {"rsp", "esp", "sp", "spl"}, reg_off(rsp, esp) },
 #undef reg_off
-#if __x86_64__
+#ifdef __x86_64__
 		{ {"r8", "r8d", "r8w", "r8b"}, offsetof(struct pt_regs, r8) },
 		{ {"r9", "r9d", "r9w", "r9b"}, offsetof(struct pt_regs, r9) },
 		{ {"r10", "r10d", "r10w", "r10b"}, offsetof(struct pt_regs, r10) },
Signature · 1 line
2.30.2
#1 lore raw
This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <[email protected]>:

Hello:

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

Quoted 7 lines · On Thu, 7 Apr 2022 13:38:42 -0700 you wrote:

As reported by Naresh:

perf build errors on i386 [1] on Linux next-20220407 [2]

usdt.c:1181:5: error: "__x86_64__" is not defined, evaluates to 0 [-Werror=undef]
1181 | #if __x86_64__

Quoted 8 lines
        |     ^~~~~~~~~~
  usdt.c:1196:5: error: "__x86_64__" is not defined, evaluates to 0
  [-Werror=undef]
   1196 | #if __x86_64__
        |     ^~~~~~~~~~

cc1: all warnings being treated as errors

[...]

Here is the summary with links:
- [bpf-next] libbpf: fix use #ifdef instead of #if to avoid compiler warning
https://git.kernel.org/bpf/bpf-next/c/ded6dffaed5e

You are awesome, thank you!

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