aboutsummaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-support/open-vm-tools/open-vm-tools/0003-use-posix-strerror_r-unless-on-gnu-libc-system.patch
blob: c7d34c5cfa9f4552797cf02b7d0ce1a6365bbbaf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
From a2e7d9273261c5c5cbc33796900f415097f5455e Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 13 Jun 2018 23:16:53 -0700
Subject: [PATCH] use posix strerror_r unless on gnu libc system

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 open-vm-tools/lib/err/errPosix.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/err/errPosix.c b/lib/err/errPosix.c
index c81b4c13..7a403640 100644
--- a/lib/err/errPosix.c
+++ b/lib/err/errPosix.c
@@ -31,6 +31,7 @@
 #include <errno.h>
 #include <string.h>
 #include <locale.h>
+#include <stdio.h>
 
 #include "vmware.h"
 #include "errInt.h"
@@ -63,11 +64,13 @@ ErrErrno2String(Err_Number errorNumber, // IN
 {
    char *p;
 
-#if defined(__linux__) && !defined(__ANDROID__)
+#if defined(__GLIBC__) && !defined(__ANDROID__)
    p = strerror_r(errorNumber, buf, bufSize);
 #else
-   p = strerror(errorNumber);
-#endif
+   if (strerror_r(errorNumber, buf, bufSize) != 0)
+      snprintf(buf, bufSize, "unknown error %i", errorNumber);
+   p = buf;
+#endif /* defined __GLIBC__ */
    ASSERT(p != NULL);
    return p;
 }