Re: [PATCH v1] libbpf: Add namespace for errstr making it libbpf_errstr
From: Andrii Nakryiko
Date: Thu Mar 20 2025 - 17:37:45 EST
On Thu, Mar 20, 2025 at 11:00 AM Ian Rogers <irogers@xxxxxxxxxx> wrote:
>
> When statically linking symbols can be replaced with those from other
> statically linked libraries depending on the link order and the hoped
> for "multiple definition" error may not appear. To avoid conflicts it
> is good practice to namespace symbols, this change renames errstr to
> libbpf_errstr.
>
> Fixes: 1633a83bf993 ("libbpf: Introduce errstr() for stringifying errno")
> Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
> ---
> I feel like this patch shouldn't be strictly necessary, it turned out
> for a use-case it was and people who know better than me say the
> linker is working as intended. The conflicting errstr was from:
> https://sourceforge.net/projects/linuxquota/
> The fixes tag may not be strictly necessary.
> ---
sigh, I do like short errstr(). How about we avoid all this churn by
naming the function libbpf_errstr() as you did, but then also
defining:
#define errstr(err) libbpf_errstr(err)
and leaving all existing invocations as is
?
pw-bot: cr
> tools/lib/bpf/btf.c | 24 ++--
> tools/lib/bpf/btf_dump.c | 2 +-
> tools/lib/bpf/elf.c | 2 +-
> tools/lib/bpf/features.c | 6 +-
> tools/lib/bpf/gen_loader.c | 2 +-
> tools/lib/bpf/libbpf.c | 228 +++++++++++++++++++------------------
> tools/lib/bpf/linker.c | 21 ++--
> tools/lib/bpf/ringbuf.c | 21 ++--
> tools/lib/bpf/str_error.c | 2 +-
> tools/lib/bpf/str_error.h | 4 +-
> tools/lib/bpf/usdt.c | 16 +--
> 11 files changed, 168 insertions(+), 160 deletions(-)
>
[...]