Skip to content

Commit

Permalink
Force the XSI version of strerror_r
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Cercueil <[email protected]>
  • Loading branch information
Paul Cercueil committed Jul 1, 2016
1 parent c1f78f7 commit 5472091
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions utilities.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
*
* */

/* Force the XSI version of strerror_r */
#undef _GNU_SOURCE

#include "iio-private.h"

#include <errno.h>
Expand Down Expand Up @@ -184,17 +187,11 @@ void iio_strerror(int err, char *buf, size_t len)
{
#ifdef _WIN32
int ret = strerror_s(buf, len, err);
if (ret != 0)
snprintf(buf, len, "Unknown error %i", err);
#elif (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE
#else
int ret = strerror_r(err, buf, len);
#endif
if (ret != 0)
snprintf(buf, len, "Unknown error %i", err);
#else
char *str = strerror_r(err, buf, len);
if (str != buf)
strncpy(buf, str, len);
#endif
}

int set_blocking_mode(int fd, bool blocking)
Expand Down

0 comments on commit 5472091

Please sign in to comment.