From e18f296f3ec35d260b38eca33621224dc674fd3d Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Thu, 19 May 2011 21:59:46 +0200 Subject: [PATCH] strerror_r: Reorder #if blocks. * lib/strerror_r.c (strerror_r): Reorder conditionals in the function for consistency with the previous commit. --- ChangeLog | 8 +++++++- lib/strerror_r.c | 22 +++++++++++----------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8eaefefdd8..db41064127 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-05-19 Bruno Haible + + strerror_r: Reorder #if blocks. + * lib/strerror_r.c (strerror_r): Reorder conditionals in the function + for consistency with the previous commit. + 2011-05-19 Bruno Haible perror: Avoid clobbering the strerror buffer when possible. @@ -13,7 +19,7 @@ 2011-05-19 Eric Blake strerror_r: fix on newer cygwin - * lib/strerror_r.c (rpl_strerror_r): Cygwin now has + * lib/strerror_r.c (strerror_r): Cygwin now has __xpg_strerror_r, use it. 2011-05-19 Bruno Haible diff --git a/lib/strerror_r.c b/lib/strerror_r.c index fe1185ba4e..db48245106 100644 --- a/lib/strerror_r.c +++ b/lib/strerror_r.c @@ -419,7 +419,17 @@ strerror_r (int errnum, char *buf, size_t buflen) { int ret; -#if USE_SYSTEM_STRERROR_R +#if USE_XPG_STRERROR_R + + { + extern int __xpg_strerror_r (int errnum, char *buf, size_t buflen); + + ret = __xpg_strerror_r (errnum, buf, buflen); + if (ret < 0) + ret = errno; + } + +#elif USE_SYSTEM_STRERROR_R if (buflen > INT_MAX) buflen = INT_MAX; @@ -495,16 +505,6 @@ strerror_r (int errnum, char *buf, size_t buflen) } } -#elif USE_XPG_STRERROR_R - - { - extern int __xpg_strerror_r (int errnum, char *buf, size_t buflen); - - ret = __xpg_strerror_r (errnum, buf, buflen); - if (ret < 0) - ret = errno; - } - #else /* USE_SYSTEM_STRERROR */ /* Try to do what strerror (errnum) does, but without clobbering the -- 2.30.2