diff options
| author | Jiayuan Chen <jiayuan.chen@linux.dev> | 2025-03-11 19:28:09 +0800 |
|---|---|---|
| committer | Andrii Nakryiko <andrii@kernel.org> | 2025-03-17 13:50:56 -0700 |
| commit | 3775be3417cc3243b0df0492bd308559dcf0560b (patch) | |
| tree | 33f45a2bcc436b5864e1676b3c2816b406bdfc7d /kernel/bpf/disasm.c | |
| parent | 8d86767be9c9b94f196e663e0ca88e2eb604a20e (diff) | |
bpftool: Using the right format specifiers
Fixed some formatting specifiers errors, such as using %d for int and %u
for unsigned int, as well as other byte-length types.
Perform type cast using the type derived from the data type itself, for
example, if it's originally an int, it will be cast to unsigned int if
forced to unsigned.
Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20250311112809.81901-3-jiayuan.chen@linux.dev
Diffstat (limited to 'kernel/bpf/disasm.c')
| -rw-r--r-- | kernel/bpf/disasm.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/kernel/bpf/disasm.c b/kernel/bpf/disasm.c index 974d172d6735..20883c6b1546 100644 --- a/kernel/bpf/disasm.c +++ b/kernel/bpf/disasm.c @@ -202,7 +202,7 @@ void print_bpf_insn(const struct bpf_insn_cbs *cbs, insn->dst_reg, class == BPF_ALU ? 'w' : 'r', insn->dst_reg); } else if (is_addr_space_cast(insn)) { - verbose(cbs->private_data, "(%02x) r%d = addr_space_cast(r%d, %d, %d)\n", + verbose(cbs->private_data, "(%02x) r%d = addr_space_cast(r%d, %u, %u)\n", insn->code, insn->dst_reg, insn->src_reg, ((u32)insn->imm) >> 16, (u16)insn->imm); } else if (is_mov_percpu_addr(insn)) { @@ -381,7 +381,7 @@ void print_bpf_insn(const struct bpf_insn_cbs *cbs, insn->code, class == BPF_JMP32 ? 'w' : 'r', insn->dst_reg, bpf_jmp_string[BPF_OP(insn->code) >> 4], - insn->imm, insn->off); + (u32)insn->imm, insn->off); } } else { verbose(cbs->private_data, "(%02x) %s\n", |