diff options
author | Philipp Janda <siffiejoe@gmx.net> | 2017-09-24 14:36:58 +0200 |
---|---|---|
committer | Philipp Janda <siffiejoe@gmx.net> | 2017-09-24 14:36:58 +0200 |
commit | 447decaaf902ad9c461a6df2bbe702481f3d7786 (patch) | |
tree | 7e5a8a5c2f9cffdf1b43b7ae3cd0edbb8d925ea2 | |
parent | b7829017581164c3e5dda24e3b187c0833b37dbf (diff) | |
download | lua-compat-5.3-strerror.tar.gz lua-compat-5.3-strerror.tar.bz2 lua-compat-5.3-strerror.zip |
Add braces and suppress warning.strerror
-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 |