Skip to content

Commit 307ef66

Browse files
captain5050anakryiko
authored andcommitted
libbpf: Add namespace for errstr making it libbpf_errstr
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: 1633a83 ("libbpf: Introduce errstr() for stringifying errno") Signed-off-by: Ian Rogers <irogers@google.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20250320222439.1350187-1-irogers@google.com
1 parent 51d6504 commit 307ef66

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

tools/lib/bpf/str_error.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ char *libbpf_strerror_r(int err, char *dst, int len)
3636
return dst;
3737
}
3838

39-
const char *errstr(int err)
39+
const char *libbpf_errstr(int err)
4040
{
4141
static __thread char buf[12];
4242

tools/lib/bpf/str_error.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,13 @@
77
char *libbpf_strerror_r(int err, char *dst, int len);
88

99
/**
10-
* @brief **errstr()** returns string corresponding to numeric errno
10+
* @brief **libbpf_errstr()** returns string corresponding to numeric errno
1111
* @param err negative numeric errno
1212
* @return pointer to string representation of the errno, that is invalidated
1313
* upon the next call.
1414
*/
15-
const char *errstr(int err);
15+
const char *libbpf_errstr(int err);
16+
17+
#define errstr(err) libbpf_errstr(err)
18+
1619
#endif /* __LIBBPF_STR_ERROR_H */

0 commit comments

Comments
 (0)