mbox series

[bpf-next,v3,0/4] libbpf: stringify error codes in log messages

Message ID 20241111212919.368971-1-mykyta.yatsenko5@gmail.com (mailing list archive)
Headers show
Series libbpf: stringify error codes in log messages | expand

Message

Mykyta Yatsenko Nov. 11, 2024, 9:29 p.m. UTC
From: Mykyta Yatsenko <yatsenko@meta.com>

Libbpf may report error in 2 ways:
 1. Numeric errno
 2. Errno's text representation, returned by strerror
Both ways may be confusing for users: numeric code requires people to
know how to find its meaning and strerror may be too generic and
unclear.

These patches modify libbpf error reporting by swapping numeric codes
and strerror with the standard short error name, for example:
"failed to attach: -22" becomes "failed to attach: -EINVAL".

Mykyta Yatsenko (4):
  libbpf: introduce errstr() for stringifying errno
  libbpf: stringify errno in log messages in libbpf.c
  libbpf: stringify errno in log messages in btf*.c
  libbpf: stringify errno in log messages in the remaining code

 tools/lib/bpf/btf.c        |  26 +--
 tools/lib/bpf/btf_dump.c   |   3 +-
 tools/lib/bpf/elf.c        |   4 +-
 tools/lib/bpf/features.c   |  15 +-
 tools/lib/bpf/gen_loader.c |   3 +-
 tools/lib/bpf/libbpf.c     | 356 ++++++++++++++++---------------------
 tools/lib/bpf/linker.c     |  21 ++-
 tools/lib/bpf/ringbuf.c    |  34 ++--
 tools/lib/bpf/str_error.c  |  59 ++++++
 tools/lib/bpf/str_error.h  |   7 +
 tools/lib/bpf/usdt.c       |  32 ++--
 11 files changed, 294 insertions(+), 266 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org Nov. 12, 2024, 4:40 a.m. UTC | #1
Hello:

This series was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Mon, 11 Nov 2024 21:29:15 +0000 you wrote:
> From: Mykyta Yatsenko <yatsenko@meta.com>
> 
> Libbpf may report error in 2 ways:
>  1. Numeric errno
>  2. Errno's text representation, returned by strerror
> Both ways may be confusing for users: numeric code requires people to
> know how to find its meaning and strerror may be too generic and
> unclear.
> 
> [...]

Here is the summary with links:
  - [bpf-next,v3,1/4] libbpf: introduce errstr() for stringifying errno
    https://git.kernel.org/bpf/bpf-next/c/1633a83bf993
  - [bpf-next,v3,2/4] libbpf: stringify errno in log messages in libbpf.c
    https://git.kernel.org/bpf/bpf-next/c/271abf041cb3
  - [bpf-next,v3,3/4] libbpf: stringify errno in log messages in btf*.c
    https://git.kernel.org/bpf/bpf-next/c/af8380d51948
  - [bpf-next,v3,4/4] libbpf: stringify errno in log messages in the remaining code
    https://git.kernel.org/bpf/bpf-next/c/4ce16ddd7105

You are awesome, thank you!