]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
libbpf: remove unused libbpf_strerror_r and STRERR_BUFSIZE
authorAndrii Nakryiko <andrii@kernel.org>
Wed, 1 Oct 2025 17:13:23 +0000 (10:13 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 1 Oct 2025 22:27:25 +0000 (15:27 -0700)
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 <andrii@kernel.org>
Link: https://lore.kernel.org/r/20251001171326.3883055-3-andrii@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
tools/lib/bpf/libbpf.c
tools/lib/bpf/str_error.c
tools/lib/bpf/str_error.h

index f92083f51bdb36e3551484369b78a70ff7f8d70c..c21bc61f5ff4ce928d743874a59575bfc7f41bfb 100644 (file)
@@ -319,8 +319,6 @@ static void pr_perm_msg(int err)
                buf);
 }
 
-#define STRERR_BUFSIZE  128
-
 /* Copied from tools/perf/util/util.h */
 #ifndef zfree
 # define zfree(ptr) ({ free(*ptr); *ptr = NULL; })
index 9a541762f54c08c7c96caa94f649148b53fe25bd..92dbd801102f3b040f57c2a4f6bc416d21cc61f4 100644 (file)
 /* make sure libbpf doesn't use kernel-only integer typedefs */
 #pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64
 
-/*
- * Wrapper to allow for building in non-GNU systems such as Alpine Linux's musl
- * libc, while checking strerror_r() return to avoid having to check this in
- * all places calling it.
- */
-char *libbpf_strerror_r(int err, char *dst, int len)
-{
-       int ret = strerror_r(err < 0 ? -err : err, dst, len);
-       /* on glibc <2.13, ret == -1 and errno is set, if strerror_r() can't
-        * handle the error, on glibc >=2.13 *positive* (errno-like) error
-        * code is returned directly
-        */
-       if (ret == -1)
-               ret = errno;
-       if (ret) {
-               if (ret == EINVAL)
-                       /* strerror_r() doesn't recognize this specific error */
-                       snprintf(dst, len, "unknown error (%d)", err < 0 ? err : -err);
-               else
-                       snprintf(dst, len, "ERROR: strerror_r(%d)=%d", err, ret);
-       }
-       return dst;
-}
-
 const char *libbpf_errstr(int err)
 {
        static __thread char buf[12];
index 53e7fbffc13ec1f434d4f88c59d826e360d97212..d4c82eec034d3d844436312e247bbb961f199ac0 100644 (file)
@@ -2,10 +2,6 @@
 #ifndef __LIBBPF_STR_ERROR_H
 #define __LIBBPF_STR_ERROR_H
 
-#define STRERR_BUFSIZE  128
-
-char *libbpf_strerror_r(int err, char *dst, int len);
-
 /**
  * @brief **libbpf_errstr()** returns string corresponding to numeric errno
  * @param err negative numeric errno