summaryrefslogtreecommitdiffstats
path: root/meta/recipes-support/libnl/libnl/0003-src-switch-to-using-strerror_l-instead-of-strerror_r.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-support/libnl/libnl/0003-src-switch-to-using-strerror_l-instead-of-strerror_r.patch')
-rw-r--r--meta/recipes-support/libnl/libnl/0003-src-switch-to-using-strerror_l-instead-of-strerror_r.patch82
1 files changed, 0 insertions, 82 deletions
diff --git a/meta/recipes-support/libnl/libnl/0003-src-switch-to-using-strerror_l-instead-of-strerror_r.patch b/meta/recipes-support/libnl/libnl/0003-src-switch-to-using-strerror_l-instead-of-strerror_r.patch
deleted file mode 100644
index a0f5a78092..0000000000
--- a/meta/recipes-support/libnl/libnl/0003-src-switch-to-using-strerror_l-instead-of-strerror_r.patch
+++ /dev/null
@@ -1,82 +0,0 @@
1From 6c2d111177e91184073c44f83d4a6182aaba06d7 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Andr=C3=A9=20Draszik?= <adraszik@tycoint.com>
3Date: Thu, 25 Aug 2016 13:15:01 +0100
4Subject: [PATCH 3/3] src: switch to using strerror_l() instead of strerror_r()
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9glibc provides two versions of strerror_r(), which
10can be chosen between using feature test macros
11_GNU_SOURCE and _POSIX_C_SOURCE. libnl is built using
12the former, hence we get the glibc special version,
13and all code so far has been written for this.
14
15Other C libraries like musl on the other hand only try
16to be posix compliant, and only ever provide the posix
17version of strerror_r(), which has a different signature.
18
19Uses in libnl hence generally cause printf() of an *int*
20with a *string format* specifier for that reason.
21
22Additionally, strerror_r() has been deprecated:
23 http://austingroupbugs.net/view.php?id=655
24
25Switch to using strerror_l().
26
27Signed-off-by: André Draszik <adraszik@tycoint.com>
28Reviewed-by: Stephane Ayotte <sayotte@tycoint.com>
29Signed-off-by: Thomas Haller <thaller@redhat.com>
30---
31Upstream-Status: Backport https://github.com/thom311/libnl/commit/6c2d111177e91184073c44f83d4a6182aaba06d7
32 src/lib/utils.c | 20 +++++++++++++++++---
33 1 file changed, 17 insertions(+), 3 deletions(-)
34
35diff --git a/src/lib/utils.c b/src/lib/utils.c
36index 467aaed..5878f27 100644
37--- a/src/lib/utils.c
38+++ b/src/lib/utils.c
39@@ -22,6 +22,7 @@
40 */
41
42 #include <netlink/cli/utils.h>
43+#include <locale.h>
44
45 /**
46 * Parse a text based 32 bit unsigned integer argument
47@@ -70,7 +71,6 @@ void nl_cli_print_version(void)
48 void nl_cli_fatal(int err, const char *fmt, ...)
49 {
50 va_list ap;
51- char buf[256];
52
53 fprintf(stderr, "Error: ");
54
55@@ -79,8 +79,22 @@ void nl_cli_fatal(int err, const char *fmt, ...)
56 vfprintf(stderr, fmt, ap);
57 va_end(ap);
58 fprintf(stderr, "\n");
59- } else
60- fprintf(stderr, "%s\n", strerror_r(err, buf, sizeof(buf)));
61+ } else {
62+ char *buf;
63+ locale_t loc = newlocale(LC_MESSAGES_MASK, "", (locale_t)0);
64+ if (loc == (locale_t)0) {
65+ if (errno == ENOENT)
66+ loc = newlocale(LC_MESSAGES_MASK,
67+ "POSIX", (locale_t)0);
68+ if (loc == (locale_t)0)
69+ buf = "newlocale() failed";
70+ }
71+ if (loc != (locale_t)0)
72+ buf = strerror_l(err, loc);
73+ fprintf(stderr, "%s\n", buf);
74+ if (loc != (locale_t)0)
75+ freelocale(loc);
76+ }
77
78 exit(abs(err));
79 }
80--
812.9.3
82