Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
0002 #undef _GNU_SOURCE
0003 #include <string.h>
0004 #include <stdio.h>
0005 #include "str_error.h"
0006 
0007 /* make sure libbpf doesn't use kernel-only integer typedefs */
0008 #pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64
0009 
0010 /*
0011  * Wrapper to allow for building in non-GNU systems such as Alpine Linux's musl
0012  * libc, while checking strerror_r() return to avoid having to check this in
0013  * all places calling it.
0014  */
0015 char *libbpf_strerror_r(int err, char *dst, int len)
0016 {
0017     int ret = strerror_r(err < 0 ? -err : err, dst, len);
0018     if (ret)
0019         snprintf(dst, len, "ERROR: strerror_r(%d)=%d", err, ret);
0020     return dst;
0021 }