1 From e15966ac7f3b43df2acf869f98089762807d0568 Mon Sep 17 00:00:00 2001
2 From: Alexey Brodkin <Alexey.Brodkin@synopsys.com>
3 Date: Fri, 10 Mar 2017 17:44:22 +0300
4 Subject: [PATCH] lib: escape usage of strerror_l() if it doesn't exist in libc
6 uClibc doesn't implement strerror_l() and thus libnl starting from
7 3.2.29 couldn't be compiled with it any longer.
9 To work-around that problem we'll just do a check on strerror_l()
10 availability during configuration and if it's not there just fall back
11 to locale-less strerror().
13 See-also: 6c2d111177e91184073c44f83d4a6182aaba06d7
15 http://lists.infradead.org/pipermail/libnl/2017-March/002301.html
17 Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
18 Signed-off-by: Thomas Haller <thaller@redhat.com>
19 Signed-off-by: Baruch Siach <baruch@tkos.co.il>
21 Patch status: upstream commit e15966ac7f3b43df
24 lib/utils.c | 8 +++++++-
25 src/lib/utils.c | 6 ++++++
26 3 files changed, 15 insertions(+), 1 deletion(-)
28 diff --git a/configure.ac b/configure.ac
29 index 68b285e5b15c..2739b997ee3a 100644
32 @@ -121,6 +121,8 @@ fi
34 AC_CONFIG_SUBDIRS([doc])
36 +AC_CHECK_FUNCS([strerror_l])
41 diff --git a/lib/utils.c b/lib/utils.c
42 index fb350d13fd2f..06273c5b291e 100644
46 #include <netlink/utils.h>
47 #include <linux/socket.h>
48 #include <stdlib.h> /* exit() */
49 +#ifdef HAVE_STRERROR_L
54 * Global variable indicating the desired level of debugging output.
55 @@ -123,9 +125,10 @@ int __nl_read_num_str_file(const char *path, int (*cb)(long, const char *))
57 const char *nl_strerror_l(int err)
60 +#ifdef HAVE_STRERROR_L
61 int errno_save = errno;
62 locale_t loc = newlocale(LC_MESSAGES_MASK, "", (locale_t)0);
65 if (loc == (locale_t)0) {
67 @@ -140,6 +143,9 @@ const char *nl_strerror_l(int err)
72 + buf = strerror(err);
77 diff --git a/src/lib/utils.c b/src/lib/utils.c
78 index 5878f279c364..feb1d4ef4056 100644
81 @@ -81,6 +81,7 @@ void nl_cli_fatal(int err, const char *fmt, ...)
82 fprintf(stderr, "\n");
85 +#ifdef HAVE_STRERROR_L
86 locale_t loc = newlocale(LC_MESSAGES_MASK, "", (locale_t)0);
87 if (loc == (locale_t)0) {
89 @@ -91,9 +92,14 @@ void nl_cli_fatal(int err, const char *fmt, ...)
91 if (loc != (locale_t)0)
92 buf = strerror_l(err, loc);
94 + buf = strerror(err);
96 fprintf(stderr, "%s\n", buf);
97 +#ifdef HAVE_STRERROR_L
98 if (loc != (locale_t)0)