]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bpf: Convert bpf_get_spilled_reg macro to static inline function
authorYonghong Song <yonghong.song@linux.dev>
Wed, 13 May 2026 04:49:54 +0000 (21:49 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 13 May 2026 16:27:30 +0000 (09:27 -0700)
Convert the bpf_get_spilled_reg() macro to a static inline function
for better type safety and readability. This also simplifies the macro
definition in preparation for upcoming stack argument support which
will introduce additional macros.

No functional change.

Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20260513044954.2382693-1-yonghong.song@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/linux/bpf_verifier.h

index c15a4c26a43bb152aa2448f2fb993bfb8209dbee..203fb751eeaeb500fc914d5ee29cb02f4d7fdd0c 100644 (file)
@@ -552,10 +552,14 @@ struct bpf_verifier_state {
        u32 may_goto_depth;
 };
 
-#define bpf_get_spilled_reg(slot, frame, mask)                         \
-       (((slot < frame->allocated_stack / BPF_REG_SIZE) &&             \
-         ((1 << frame->stack[slot].slot_type[BPF_REG_SIZE - 1]) & (mask))) \
-        ? &frame->stack[slot].spilled_ptr : NULL)
+static inline struct bpf_reg_state *
+bpf_get_spilled_reg(int slot, struct bpf_func_state *frame, u32 mask)
+{
+       if (slot < frame->allocated_stack / BPF_REG_SIZE &&
+           (1 << frame->stack[slot].slot_type[BPF_REG_SIZE - 1]) & mask)
+               return &frame->stack[slot].spilled_ptr;
+       return NULL;
+}
 
 /* Iterate over 'frame', setting 'reg' to either NULL or a spilled register. */
 #define bpf_for_each_spilled_reg(iter, frame, reg, mask)                       \