[lttng-dev] [PATCH babeltrace stable-1.5 1/5] Port: replace strerror_r() with glib g_strerror()
Jérémie Galarneau
jeremie.galarneau at efficios.com
Tue Feb 21 03:01:35 UTC 2017
All patches were merged in stable-1.5.
Thanks!
Jérémie
On 2 February 2017 at 17:03, Michael Jeanson <mjeanson at efficios.com> wrote:
> Signed-off-by: Michael Jeanson <mjeanson at efficios.com>
> Acked-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> ---
> configure.ac | 1 -
> include/babeltrace/babeltrace-internal.h | 12 ++++++------
> include/babeltrace/compat/string.h | 26 --------------------------
> 3 files changed, 6 insertions(+), 33 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 56255d0..6d097bb 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -97,7 +97,6 @@ AC_FUNC_MALLOC
> AC_FUNC_MKTIME
> AC_FUNC_MMAP
> AC_FUNC_REALLOC
> -AC_FUNC_STRERROR_R
> AC_CHECK_FUNCS([ \
> atexit \
> dirfd \
> diff --git a/include/babeltrace/babeltrace-internal.h b/include/babeltrace/babeltrace-internal.h
> index a903c68..0e73cdb 100644
> --- a/include/babeltrace/babeltrace-internal.h
> +++ b/include/babeltrace/babeltrace-internal.h
> @@ -83,16 +83,16 @@ extern int babeltrace_verbose, babeltrace_debug;
>
> #define _bt_printf_perror(fp, fmt, args...) \
> ({ \
> - char buf[PERROR_BUFLEN] = "Error in strerror_r()"; \
> - compat_strerror_r(errno, buf, sizeof(buf)); \
> - _bt_printfe(fp, "error", buf, fmt, ## args); \
> + const char *errstr; \
> + errstr = g_strerror(errno); \
> + _bt_printfe(fp, "error", errstr, fmt, ## args); \
> })
>
> #define _bt_printfl_perror(fp, lineno, fmt, args...) \
> ({ \
> - char buf[PERROR_BUFLEN] = "Error in strerror_r()"; \
> - compat_strerror_r(errno, buf, sizeof(buf)); \
> - _bt_printfle(fp, "error", lineno, buf, fmt, ## args); \
> + const char *errstr; \
> + errstr = g_strerror(errno); \
> + _bt_printfle(fp, "error", lineno, errstr, fmt, ## args);\
> })
>
> /* printf without lineno information */
> diff --git a/include/babeltrace/compat/string.h b/include/babeltrace/compat/string.h
> index 6092616..c3325a3 100644
> --- a/include/babeltrace/compat/string.h
> +++ b/include/babeltrace/compat/string.h
> @@ -26,32 +26,6 @@
> #include <string.h>
> #include <stdlib.h>
>
> -#if !defined(__GLIBC__) || ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !defined(_GNU_SOURCE))
> -
> -/* XSI-compliant strerror_r */
> -static inline
> -int compat_strerror_r(int errnum, char *buf, size_t buflen)
> -{
> - return strerror_r(errnum, buf, buflen);
> -}
> -
> -#else
> -
> -/* GNU-compliant strerror_r */
> -static inline
> -int compat_strerror_r(int errnum, char *buf, size_t buflen)
> -{
> - char *retbuf;
> -
> - retbuf = strerror_r(errnum, buf, buflen);
> - if (retbuf != buf)
> - strncpy(buf, retbuf, buflen);
> - buf[buflen - 1] = '\0';
> - return 0;
> -}
> -
> -#endif
> -
> #ifdef HAVE_STRNLEN
> static inline
> size_t bt_strnlen(const char *str, size_t max)
> --
> 2.7.4
>
--
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com
More information about the lttng-dev
mailing list