bpf,arena: Use helper sizeof_field in struct accessors
authorHaiyue Wang <haiyue.wang@intel.com>
Wed, 27 Mar 2024 06:53:29 +0000 (14:53 +0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 29 Mar 2024 01:31:36 +0000 (18:31 -0700)
Use the well defined helper sizeof_field() to calculate the size of a
struct member, instead of doing custom calculations.

Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
Link: https://lore.kernel.org/r/20240327065334.8140-1-haiyue.wang@intel.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/arena.c

index 343c3456c8ddf0e6352a5f2614627c316078077a..6c81630c52934e2754fab94b001ef67b3468db6d 100644 (file)
@@ -37,7 +37,7 @@
  */
 
 /* number of bytes addressable by LDX/STX insn with 16-bit 'off' field */
-#define GUARD_SZ (1ull << sizeof(((struct bpf_insn *)0)->off) * 8)
+#define GUARD_SZ (1ull << sizeof_field(struct bpf_insn, off) * 8)
 #define KERN_VM_SZ (SZ_4G + GUARD_SZ)
 
 struct bpf_arena {