BPF List
 help / color / mirror / Atom feed
* [PATCH v2] libbpf: Add namespace for errstr making it libbpf_errstr
@ 2025-03-20 22:24 Ian Rogers
  2025-03-21 20:50 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Ian Rogers @ 2025-03-20 22:24 UTC (permalink / raw)
  To: Andrii Nakryiko, Eduard Zingerman, Alexei Starovoitov,
	Daniel Borkmann, Martin KaFai Lau, Song Liu, Yonghong Song,
	John Fastabend, KP Singh, Stanislav Fomichev, Hao Luo, Jiri Olsa,
	Mykyta Yatsenko, bpf, linux-kernel
  Cc: Ian Rogers

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. To avoid churn a #define is used to turn use of
errstr(err) to libbpf_errstr(err).

Fixes: 1633a83bf993 ("libbpf: Introduce errstr() for stringifying errno")
Signed-off-by: Ian Rogers <irogers@google.com>
---
v2: Use #define to avoid churn renaming errstr as suggested by Andrii
    Nakryiko <andrii@kernel.org>.

v1: 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.
---
 tools/lib/bpf/str_error.c | 2 +-
 tools/lib/bpf/str_error.h | 7 +++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/tools/lib/bpf/str_error.c b/tools/lib/bpf/str_error.c
index 8743049e32b7..9a541762f54c 100644
--- a/tools/lib/bpf/str_error.c
+++ b/tools/lib/bpf/str_error.c
@@ -36,7 +36,7 @@ char *libbpf_strerror_r(int err, char *dst, int len)
 	return dst;
 }
 
-const char *errstr(int err)
+const char *libbpf_errstr(int err)
 {
 	static __thread char buf[12];
 
diff --git a/tools/lib/bpf/str_error.h b/tools/lib/bpf/str_error.h
index 66ffebde0684..53e7fbffc13e 100644
--- a/tools/lib/bpf/str_error.h
+++ b/tools/lib/bpf/str_error.h
@@ -7,10 +7,13 @@
 char *libbpf_strerror_r(int err, char *dst, int len);
 
 /**
- * @brief **errstr()** returns string corresponding to numeric errno
+ * @brief **libbpf_errstr()** returns string corresponding to numeric errno
  * @param err negative numeric errno
  * @return pointer to string representation of the errno, that is invalidated
  * upon the next call.
  */
-const char *errstr(int err);
+const char *libbpf_errstr(int err);
+
+#define errstr(err) libbpf_errstr(err)
+
 #endif /* __LIBBPF_STR_ERROR_H */
-- 
2.49.0.395.g12beb8f557-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] libbpf: Add namespace for errstr making it libbpf_errstr
  2025-03-20 22:24 [PATCH v2] libbpf: Add namespace for errstr making it libbpf_errstr Ian Rogers
@ 2025-03-21 20:50 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-03-21 20:50 UTC (permalink / raw)
  To: Ian Rogers
  Cc: andrii, eddyz87, ast, daniel, martin.lau, song, yonghong.song,
	john.fastabend, kpsingh, sdf, haoluo, jolsa, yatsenko, bpf,
	linux-kernel

Hello:

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

On Thu, 20 Mar 2025 15:24:39 -0700 you 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. To avoid churn a #define is used to turn use of
> errstr(err) to libbpf_errstr(err).
> 
> [...]

Here is the summary with links:
  - [v2] libbpf: Add namespace for errstr making it libbpf_errstr
    https://git.kernel.org/bpf/bpf-next/c/307ef667e945

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-03-21 20:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-20 22:24 [PATCH v2] libbpf: Add namespace for errstr making it libbpf_errstr Ian Rogers
2025-03-21 20:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox