Skip to content

Commit ac1bcae

Browse files
anakryikoKernel Patches Daemon
authored andcommitted
libbpf: remove unused libbpf_strerror_r and STRERR_BUFSIZE
libbpf_strerror_r() is not exposed as public API and neither is it used inside libbpf itself. Remove it altogether. Same for STRERR_BUFSIZE, it's just an orphaned leftover constant which we missed to clean up some time earlier. Signed-off-by: Andrii Nakryiko <[email protected]>
1 parent f51f09a commit ac1bcae

File tree

3 files changed

+0
-30
lines changed

3 files changed

+0
-30
lines changed

tools/lib/bpf/libbpf.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,6 @@ static void pr_perm_msg(int err)
319319
buf);
320320
}
321321

322-
#define STRERR_BUFSIZE 128
323-
324322
/* Copied from tools/perf/util/util.h */
325323
#ifndef zfree
326324
# define zfree(ptr) ({ free(*ptr); *ptr = NULL; })

tools/lib/bpf/str_error.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,6 @@
1212
/* make sure libbpf doesn't use kernel-only integer typedefs */
1313
#pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64
1414

15-
/*
16-
* Wrapper to allow for building in non-GNU systems such as Alpine Linux's musl
17-
* libc, while checking strerror_r() return to avoid having to check this in
18-
* all places calling it.
19-
*/
20-
char *libbpf_strerror_r(int err, char *dst, int len)
21-
{
22-
int ret = strerror_r(err < 0 ? -err : err, dst, len);
23-
/* on glibc <2.13, ret == -1 and errno is set, if strerror_r() can't
24-
* handle the error, on glibc >=2.13 *positive* (errno-like) error
25-
* code is returned directly
26-
*/
27-
if (ret == -1)
28-
ret = errno;
29-
if (ret) {
30-
if (ret == EINVAL)
31-
/* strerror_r() doesn't recognize this specific error */
32-
snprintf(dst, len, "unknown error (%d)", err < 0 ? err : -err);
33-
else
34-
snprintf(dst, len, "ERROR: strerror_r(%d)=%d", err, ret);
35-
}
36-
return dst;
37-
}
38-
3915
const char *libbpf_errstr(int err)
4016
{
4117
static __thread char buf[12];

tools/lib/bpf/str_error.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22
#ifndef __LIBBPF_STR_ERROR_H
33
#define __LIBBPF_STR_ERROR_H
44

5-
#define STRERR_BUFSIZE 128
6-
7-
char *libbpf_strerror_r(int err, char *dst, int len);
8-
95
/**
106
* @brief **libbpf_errstr()** returns string corresponding to numeric errno
117
* @param err negative numeric errno

0 commit comments

Comments
 (0)