Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
d4b5308d
Unverified
Commit
d4b5308d
authored
Aug 22, 2018
by
Christian Brauner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
log: handle strerror_r() versions
Closes #2563. Signed-off-by:
Christian Brauner
<
christian.brauner@ubuntu.com
>
parent
5ac017fb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
15 deletions
+37
-15
configure.ac
configure.ac
+6
-0
log.h
src/lxc/log.h
+31
-15
No files found.
configure.ac
View file @
d4b5308d
...
@@ -611,6 +611,12 @@ AC_HEADER_MAJOR
...
@@ -611,6 +611,12 @@ AC_HEADER_MAJOR
# Check for some syscalls functions
# Check for some syscalls functions
AC_CHECK_FUNCS([setns pivot_root sethostname unshare rand_r confstr faccessat gettid memfd_create])
AC_CHECK_FUNCS([setns pivot_root sethostname unshare rand_r confstr faccessat gettid memfd_create])
# Check for strerror_r() support. Defines:
# - HAVE_STRERROR_R if available
# - HAVE_DECL_STRERROR_R if defined
# - STRERROR_R_CHAR_P if it returns char *
AC_FUNC_STRERROR_R
# Check for some functions
# Check for some functions
AC_CHECK_LIB(pthread, main)
AC_CHECK_LIB(pthread, main)
AC_CHECK_FUNCS(statvfs)
AC_CHECK_FUNCS(statvfs)
...
...
src/lxc/log.h
View file @
d4b5308d
...
@@ -327,22 +327,38 @@ ATTR_UNUSED static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \
...
@@ -327,22 +327,38 @@ ATTR_UNUSED static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo, \
/*
/*
* Helper macro to define errno string.
* Helper macro to define errno string.
*/
*/
#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE) || IS_BIONIC
#if HAVE_STRERROR_R
#define lxc_log_strerror_r \
#ifndef HAVE_DECL_STRERROR_R
char errno_buf[MAXPATHLEN / 2] = {"Failed to get errno string"}; \
#ifdef STRERROR_R_CHAR_P
char *ptr = errno_buf; \
char
*
strerror_r
(
int
errnum
,
char
*
buf
,
size_t
buflen
);
{ \
#else
(void)strerror_r(errno, errno_buf, sizeof(errno_buf)); \
int
strerror_r
(
int
errnum
,
char
*
buf
,
size_t
buflen
);
}
#endif
#endif
#ifdef STRERROR_R_CHAR_P
#define lxc_log_strerror_r \
char errno_buf[MAXPATHLEN / 2] = {"Failed to get errno string"}; \
char *ptr = NULL; \
{ \
ptr = strerror_r(errno, errno_buf, sizeof(errno_buf)); \
if (!ptr) \
ptr = errno_buf; \
}
#else
#define lxc_log_strerror_r \
char errno_buf[MAXPATHLEN / 2] = {"Failed to get errno string"}; \
char *ptr = errno_buf; \
{ \
(void)strerror_r(errno, errno_buf, sizeof(errno_buf)); \
}
#endif
#else
#else
#define lxc_log_strerror_r \
#define lxc_log_strerror_r \
char errno_buf[MAXPATHLEN / 2] = {"Failed to get errno string"}; \
char *ptr = NULL; \
char *ptr; \
{ \
{ \
ptr = strerror(errno); \
ptr = strerror_r(errno, errno_buf, sizeof(errno_buf)); \
}
if (!ptr) \
ptr = errno_buf; \
}
#endif
#endif
/*
/*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment