diff options
Diffstat (limited to 'c-api')
-rw-r--r-- | c-api/compat-5.3.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/c-api/compat-5.3.c b/c-api/compat-5.3.c index 9b304c1..09c60dd 100644 --- a/c-api/compat-5.3.c +++ b/c-api/compat-5.3.c | |||
@@ -56,12 +56,16 @@ static char* compat53_strerror (int en, char* buff, size_t sz) { | |||
56 | if (sz > 0) { | 56 | if (sz > 0) { |
57 | buff[0] = '\0'; | 57 | buff[0] = '\0'; |
58 | /* we don't care whether the GNU version or the XSI version is used: */ | 58 | /* we don't care whether the GNU version or the XSI version is used: */ |
59 | strerror_r(en, buff, sz); | 59 | if (strerror_r(en, buff, sz)) { |
60 | if (buff[0] == '\0') | 60 | /* Yes, we really DO want to ignore the return value! |
61 | /* buffer is unchanged, so we probably have called GNU strerror_r which | 61 | * GCC makes that extra hard, not even a (void) cast will do. */ |
62 | } | ||
63 | if (buff[0] == '\0') { | ||
64 | /* Buffer is unchanged, so we probably have called GNU strerror_r which | ||
62 | * returned a static constant string. Chances are that strerror will | 65 | * returned a static constant string. Chances are that strerror will |
63 | * return the same static constant string and therefore be thread-safe. */ | 66 | * return the same static constant string and therefore be thread-safe. */ |
64 | return strerror(en); | 67 | return strerror(en); |
68 | } | ||
65 | } | 69 | } |
66 | return buff; /* sz is 0 *or* strerror_r wrote into the buffer */ | 70 | return buff; /* sz is 0 *or* strerror_r wrote into the buffer */ |
67 | #elif COMPAT53_HAVE_STRERROR_S | 71 | #elif COMPAT53_HAVE_STRERROR_S |