Wouldn't it be cleaner if we put this macro in logsys.h:

#define log_perror(err_num, level, format, args...) do { \
...
#endif

Then use it like a normal log function:
log_perror(errno, LOG_ERR, "bad stuff");

It then logs:
ERR bad stuff : <error string>

-Angus

On Fri, Jun 24, 2011 at 03:17:50PM +0200, Jerome Flesch wrote:
> Signed-off-by: Jerome Flesch <jerome.fle...@netasq.com>
> ---
>  exec/coroipcs.c    |   18 +++++++++++-------
>  exec/coroparse.c   |    5 +++--
>  exec/coropoll.c    |    6 ++++--
>  exec/logsys.c      |    7 +++++--
>  exec/main.c        |   15 +++++++++------
>  exec/totemconfig.c |    9 +++++----
>  exec/totemsrp.c    |   15 +++++++++------
>  exec/totemudp.c    |   36 ++++++++++++++++++++++--------------
>  exec/totemudpu.c   |   39 +++++++++++++++++++++++----------------
>  exec/util.h        |   12 ++++++++++++
>  lcr/uis.c          |   12 ++++++++++--
>  11 files changed, 113 insertions(+), 61 deletions(-)
> 
> diff --git a/exec/coroipcs.c b/exec/coroipcs.c
> index e06acb5..144173c 100644
> --- a/exec/coroipcs.c
> +++ b/exec/coroipcs.c
> @@ -1041,8 +1041,9 @@ static void _corosync_ipc_init(void)
>       res = fcntl (server_fd, F_SETFL, O_NONBLOCK);
>       if (res == -1) {
>               char error_str[100];
> -             strerror_r (errno, error_str, 100);
> -             log_printf (LOGSYS_LEVEL_CRIT, "Could not set non-blocking 
> operation on server socket: %s\n", error_str);
> +             const char *error_ptr;
> +             CS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
> +             log_printf (LOGSYS_LEVEL_CRIT, "Could not set non-blocking 
> operation on server socket: %s\n", error_ptr);
>               api->fatal_error ("Could not set non-blocking operation on 
> server socket");
>       }
>  
> @@ -1070,8 +1071,9 @@ static void _corosync_ipc_init(void)
>       res = bind (server_fd, (struct sockaddr *)&un_addr, 
> COROSYNC_SUN_LEN(&un_addr));
>       if (res) {
>               char error_str[100];
> -             strerror_r (errno, error_str, 100);
> -             log_printf (LOGSYS_LEVEL_CRIT, "Could not bind AF_UNIX (%s): 
> %s.\n", un_addr.sun_path, error_str);
> +             const char *error_ptr;
> +             CS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
> +             log_printf (LOGSYS_LEVEL_CRIT, "Could not bind AF_UNIX (%s): 
> %s.\n", un_addr.sun_path, error_ptr);
>               api->fatal_error ("Could not bind to AF_UNIX socket\n");
>       }
>  
> @@ -1478,16 +1480,18 @@ retry_accept:
>  
>       if (new_fd == -1) {
>               char error_str[100];
> -             strerror_r (errno, error_str, 100);
> +             const char *error_ptr;
> +             CS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
>               log_printf (LOGSYS_LEVEL_ERROR,
> -                     "Could not accept Library connection: %s\n", error_str);
> +                     "Could not accept Library connection: %s\n", error_ptr);
>               return (0); /* This is an error, but -1 would indicate 
> disconnect from poll loop */
>       }
>  
>       res = fcntl (new_fd, F_SETFL, O_NONBLOCK);
>       if (res == -1) {
>               char error_str[100];
> -             strerror_r (errno, error_str, 100);
> +             const char *error_ptr;
> +             CS_STRERROR_R (error_ptr, errno, error_str, 100);
>               log_printf (LOGSYS_LEVEL_ERROR,
>                       "Could not set non-blocking operation on library 
> connection: %s\n",
>                       error_str);
> diff --git a/exec/coroparse.c b/exec/coroparse.c
> index 488e1e9..80c98eb 100644
> --- a/exec/coroparse.c
> +++ b/exec/coroparse.c
> @@ -360,10 +360,11 @@ static int read_config_file_into_objdb(
>       fp = fopen (filename, "r");
>       if (fp == NULL) {
>               char error_str[100];
> -             strerror_r (errno, error_str, 100);
> +             const char *error_ptr;
> +             CS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
>               snprintf (error_reason, sizeof(error_string_response),
>                       "Can't read file %s reason = (%s)\n",
> -                      filename, error_str);
> +                      filename, error_ptr);
>               *error_string = error_reason;
>               return -1;
>       }
> diff --git a/exec/coropoll.c b/exec/coropoll.c
> index 4fc30a2..5691742 100644
> --- a/exec/coropoll.c
> +++ b/exec/coropoll.c
> @@ -49,6 +49,7 @@
>  #include <corosync/totem/coropoll.h>
>  #include <corosync/list.h>
>  #include "tlist.h"
> +#include "util.h"
>  
>  typedef int (*dispatch_fn_t) (hdb_handle_t hdb_handle, int fd, int revents, 
> void *data);
>  
> @@ -419,8 +420,9 @@ static void poll_fds_usage_check(struct poll_instance 
> *poll_instance)
>       if (socks_limit == 0) {
>               if (getrlimit(RLIMIT_NOFILE, &lim) == -1) {
>                       char error_str[100];
> -                     strerror_r(errno, error_str, 100);
> -                     printf("getrlimit: %s\n", error_str);
> +                     const char *error_ptr;
> +                     CS_STRERROR_R (error_ptr, errno, error_str, 
> sizeof(error_str));
> +                     printf("getrlimit: %s\n", error_ptr);
>                       return;
>               }
>               socks_limit = lim.rlim_cur;
> diff --git a/exec/logsys.c b/exec/logsys.c
> index 06f5aaf..ca737e4 100644
> --- a/exec/logsys.c
> +++ b/exec/logsys.c
> @@ -66,6 +66,8 @@
>  #include <corosync/list.h>
>  #include <corosync/engine/logsys.h>
>  
> +#include "util.h"
> +
>  #define YIELD_AFTER_LOG_OPS 10
>  
>  #define MIN(x,y) ((x) < (y) ? (x) : (y))
> @@ -904,13 +906,14 @@ static int logsys_config_file_set_unlocked (
>       logsys_loggers[subsysid].logfile_fp = fopen (file, "a+");
>       if (logsys_loggers[subsysid].logfile_fp == NULL) {
>               char error_str[100];
> -             strerror_r (errno, error_str, 100);
> +             const char *error_ptr;
> +             CS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
>               free(logsys_loggers[subsysid].logfile);
>               logsys_loggers[subsysid].logfile = NULL;
>               snprintf (error_string_response,
>                       sizeof(error_string_response),
>                       "Can't open logfile '%s' for reason (%s).\n",
> -                              file, error_str);
> +                              file, error_ptr);
>               *error_string = error_string_response;
>               return (-1);
>       }
> diff --git a/exec/main.c b/exec/main.c
> index e9a45e2..03312a4 100644
> --- a/exec/main.c
> +++ b/exec/main.c
> @@ -596,10 +596,11 @@ static void corosync_mlockall (void)
>       res = mlockall (MCL_CURRENT | MCL_FUTURE);
>       if (res == -1) {
>               char error_str[100];
> -             strerror_r (errno, error_str, 100);
> +             const char *error_ptr;
> +             CS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
>               log_printf (LOGSYS_LEVEL_WARNING,
>                       "Could not lock memory of service to avoid page faults: 
> %s\n",
> -                     error_str);
> +                     error_ptr);
>       };
>  #endif
>  }
> @@ -1304,9 +1305,10 @@ static void corosync_setscheduler (void)
>               res = sched_setscheduler (0, SCHED_RR, &global_sched_param);
>               if (res == -1) {
>                       char error_str[100];
> -                     strerror_r (errno, error_str, 100);
> +                     const char *error_ptr;
> +                     CS_STRERROR_R (error_ptr, errno, error_str, 
> sizeof(error_str));
>                       log_printf (LOGSYS_LEVEL_WARNING, "Could not set 
> SCHED_RR at priority %d: %s\n",
> -                             global_sched_param.sched_priority, error_str);
> +                             global_sched_param.sched_priority, error_ptr);
>  
>                       global_sched_param.sched_priority = 0;
>                       logsys_thread_priority_set (SCHED_OTHER, NULL, 1);
> @@ -1329,10 +1331,11 @@ static void corosync_setscheduler (void)
>               }
>       } else {
>               char error_str[100];
> -             strerror_r (errno, error_str, 100);
> +             const char *error_ptr;
> +             CS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
>               log_printf (LOGSYS_LEVEL_WARNING,
>                       "Could not get maximum scheduler priority: %s\n",
> -                     error_str);
> +                     error_ptr);
>               sched_priority = 0;
>       }
>  #else
> diff --git a/exec/totemconfig.c b/exec/totemconfig.c
> index 5ce171c..792074a 100644
> --- a/exec/totemconfig.c
> +++ b/exec/totemconfig.c
> @@ -745,13 +745,14 @@ static int read_keyfile (
>       ssize_t expected_key_len = sizeof (totem_config->private_key);
>       int saved_errno;
>       char error_str[100];
> +     const char *error_ptr;
>  
>       fd = open (key_location, O_RDONLY);
>       if (fd == -1) {
> -             strerror_r (errno, error_str, 100);
> +             CS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
>               snprintf (error_string_response, sizeof(error_string_response),
>                       "Could not open %s: %s\n",
> -                      key_location, error_str);
> +                      key_location, error_ptr);
>               goto parse_error;
>       }
>  
> @@ -760,10 +761,10 @@ static int read_keyfile (
>       close (fd);
>  
>       if (res == -1) {
> -             strerror_r (saved_errno, error_str, 100);
> +             CS_STRERROR_R (error_ptr, saved_errno, error_str, 
> sizeof(error_str));
>               snprintf (error_string_response, sizeof(error_string_response),
>                       "Could not read %s: %s\n",
> -                      key_location, error_str);
> +                      key_location, error_ptr);
>               goto parse_error;
>       }
>  
> diff --git a/exec/totemsrp.c b/exec/totemsrp.c
> index 678fa64..e01a40d 100644
> --- a/exec/totemsrp.c
> +++ b/exec/totemsrp.c
> @@ -90,6 +90,7 @@
>  
>  #include "crypto.h"
>  #include "tlist.h"
> +#include "util.h"
>  
>  #define LOCALHOST_IP                         inet_addr("127.0.0.1")
>  #define QUEUE_RTR_ITEMS_SIZE_MAX             16384 /* allow 16384 retransmit 
> items */
> @@ -3118,6 +3119,7 @@ static void memb_ring_id_create_or_load (
>       int res = 0;
>       char filename[PATH_MAX];
>       char error_str[256];
> +     const char *error_ptr;
>  
>       snprintf (filename, sizeof(filename), "%s/ringid_%s",
>               rundir, totemip_print (&instance->my_id.addr[0]));
> @@ -3140,16 +3142,16 @@ static void memb_ring_id_create_or_load (
>                       res = write (fd, &memb_ring_id->seq, sizeof (uint64_t));
>                       close (fd);
>                       if (res == -1) {
> -                             strerror_r (errno, error_str, sizeof 
> (error_str));
> +                             CS_STRERROR_R (error_ptr, errno, error_str, 
> sizeof (error_str));
>                               log_printf 
> (instance->totemsrp_log_level_warning,
>                                       "Couldn't write ringid file '%s' %s\n",
> -                                     filename, error_str);
> +                                     filename, error_ptr);
>                       }
>               } else {
> -                     strerror_r (errno, error_str, sizeof (error_str));
> +                     CS_STRERROR_R (error_ptr, errno, error_str, sizeof 
> (error_str));
>                       log_printf (instance->totemsrp_log_level_warning,
>                               "Couldn't create ringid file '%s' %s\n",
> -                             filename, error_str);
> +                             filename, error_ptr);
>               }
>       }
>  
> @@ -3177,10 +3179,11 @@ static void memb_ring_id_set_and_store (
>       }
>       if (fd == -1) {
>               char error_str[100];
> -             strerror_r(errno, error_str, 100);
> +             const char *error_ptr;
> +             CS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
>               log_printf (instance->totemsrp_log_level_warning,
>                       "Couldn't store new ring id %llx to stable storage 
> (%s)\n",
> -                             instance->my_ring_id.seq, error_str);
> +                             instance->my_ring_id.seq, error_ptr);
>               assert (0);
>               return;
>       }
> diff --git a/exec/totemudp.c b/exec/totemudp.c
> index 27076a7..b7124f8 100644
> --- a/exec/totemudp.c
> +++ b/exec/totemudp.c
> @@ -69,6 +69,7 @@
>  #include "wthread.h"
>  
>  #include "crypto.h"
> +#include "util.h"
>  
>  #ifdef HAVE_LIBNSS
>  #include <nss.h>
> @@ -962,9 +963,10 @@ static inline void ucast_sendmsg (
>               MSG_NOSIGNAL);
>       if (res < 0) {
>               char error_str[100];
> -             strerror_r (errno, error_str, sizeof(error_str));
> +             const char *error_ptr;
> +             CS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
>               log_printf (instance->totemudp_log_level_debug,
> -                             "sendmsg(ucast) failed (non-critical): %s\n", 
> error_str);
> +                             "sendmsg(ucast) failed (non-critical): %s\n", 
> error_ptr);
>       }
>  }
>  
> @@ -1047,9 +1049,10 @@ static inline void mcast_sendmsg (
>               MSG_NOSIGNAL);
>       if (res < 0) {
>               char error_str[100];
> -             strerror_r (errno, error_str, sizeof(error_str));
> +             const char *error_ptr;
> +             CS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
>               log_printf (instance->totemudp_log_level_debug,
> -                             "sendmsg(mcast) failed (non-critical): %s\n", 
> error_str);
> +                             "sendmsg(mcast) failed (non-critical): %s\n", 
> error_ptr);
>       }
>  }
>  
> @@ -1127,9 +1130,10 @@ static void totemudp_mcast_worker_fn (void 
> *thread_state, void *work_item_in)
>               MSG_NOSIGNAL);
>       if (res < 0) {
>               char error_str[100];
> -             strerror_r (errno, error_str, sizeof(error_str));
> +             const char *error_ptr;
> +             CS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
>               log_printf (instance->totemudp_log_level_debug,
> -                             "sendmsg(mcast) failed (non-critical): %s\n", 
> error_str);
> +                             "sendmsg(mcast) failed (non-critical): %s\n", 
> error_ptr);
>       }
>  }
>  
> @@ -1400,11 +1404,12 @@ static void totemudp_traffic_control_set(struct 
> totemudp_instance *instance, int
>  #ifdef SO_PRIORITY
>       int prio = 6; /* TC_PRIO_INTERACTIVE */
>       char error_str[100];
> +     const char *error_ptr;
>  
>       if (setsockopt(sock, SOL_SOCKET, SO_PRIORITY, &prio, sizeof(int))) {
> -             strerror_r (errno, error_str, 100);
> +             CS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
>               log_printf (instance->totemudp_log_level_warning,
> -                     "Could not set traffic priority. (%s)\n", error_str);
> +                     "Could not set traffic priority. (%s)\n", error_ptr);
>      }
>  #endif
>  }
> @@ -1444,9 +1449,10 @@ static int totemudp_build_sockets_ip (
>       res = fcntl (sockets->mcast_recv, F_SETFL, O_NONBLOCK);
>       if (res == -1) {
>               char error_str[100];
> -             strerror_r (errno, error_str, 100);
> +             const char *error_ptr;
> +             CS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
>               log_printf (instance->totemudp_log_level_warning,
> -                     "Could not set non-blocking operation on multicast 
> socket: %s\n", error_str);
> +                     "Could not set non-blocking operation on multicast 
> socket: %s\n", error_ptr);
>               return (-1);
>       }
>  
> @@ -1483,9 +1489,10 @@ static int totemudp_build_sockets_ip (
>       res = fcntl (sockets->mcast_send, F_SETFL, O_NONBLOCK);
>       if (res == -1) {
>               char error_str[100];
> -             strerror_r (errno, error_str, 100);
> +             const char *error_ptr;
> +             CS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
>               log_printf (instance->totemudp_log_level_warning,
> -                     "Could not set non-blocking operation on multicast 
> socket: %s\n", error_str);
> +                     "Could not set non-blocking operation on multicast 
> socket: %s\n", error_ptr);
>               return (-1);
>       }
>  
> @@ -1519,9 +1526,10 @@ static int totemudp_build_sockets_ip (
>       res = fcntl (sockets->token, F_SETFL, O_NONBLOCK);
>       if (res == -1) {
>               char error_str[100];
> -             strerror_r (errno, error_str, 100);
> +             const char *error_ptr;
> +             CS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
>               log_printf (instance->totemudp_log_level_warning,
> -                     "Could not set non-blocking operation on token socket: 
> %s\n", error_str);
> +                     "Could not set non-blocking operation on token socket: 
> %s\n", error_ptr);
>               return (-1);
>       }
>  
> diff --git a/exec/totemudpu.c b/exec/totemudpu.c
> index c18e59f..f2b01eb 100644
> --- a/exec/totemudpu.c
> +++ b/exec/totemudpu.c
> @@ -67,6 +67,7 @@
>  #include "totemudpu.h"
>  
>  #include "crypto.h"
> +#include "util.h"
>  
>  #ifdef HAVE_LIBNSS
>  #include <nss.h>
> @@ -942,9 +943,10 @@ static inline void ucast_sendmsg (
>       res = sendmsg (instance->token_socket, &msg_ucast, MSG_NOSIGNAL);
>       if (res < 0) {
>               char error_str[100];
> -             strerror_r (errno, error_str, sizeof(error_str));
> +             const char *error_ptr;
> +             CS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
>               log_printf (instance->totemudpu_log_level_debug,
> -                             "sendmsg(ucast) failed (non-critical): %s\n", 
> error_str);
> +                             "sendmsg(ucast) failed (non-critical): %s\n", 
> error_ptr);
>       }
>  }
>  
> @@ -1035,9 +1037,10 @@ static inline void mcast_sendmsg (
>               res = sendmsg (member->fd, &msg_mcast, MSG_NOSIGNAL);
>               if (res < 0) {
>                       char error_str[100];
> -                     strerror_r (errno, error_str, sizeof(error_str));
> +                     const char *error_ptr;
> +                     CS_STRERROR_R (error_ptr, errno, error_str, 
> sizeof(error_str));
>                       log_printf (instance->totemudpu_log_level_debug,
> -                             "sendmsg(mcast) failed (non-critical): %s\n", 
> error_str);
> +                             "sendmsg(mcast) failed (non-critical): %s\n", 
> error_ptr);
>               }
>       }
>  }
> @@ -1280,11 +1283,12 @@ static void totemudpu_traffic_control_set(struct 
> totemudpu_instance *instance, i
>  #ifdef SO_PRIORITY
>       int prio = 6; /* TC_PRIO_INTERACTIVE */
>       char error_str[100];
> +     const char *error_ptr;
>  
>       if (setsockopt(sock, SOL_SOCKET, SO_PRIORITY, &prio, sizeof(int))) {
> -             strerror_r (errno, error_str, 100);
> +             CS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
>               log_printf (instance->totemudpu_log_level_warning,
> -                     "Could not set traffic priority. (%s)\n", error_str);
> +                     "Could not set traffic priority. (%s)\n", error_ptr);
>      }
>  #endif
>  }
> @@ -1314,9 +1318,10 @@ static int totemudpu_build_sockets_ip (
>       res = fcntl (instance->token_socket, F_SETFL, O_NONBLOCK);
>       if (res == -1) {
>               char error_str[100];
> -             strerror_r (errno, error_str, 100);
> +             const char *error_ptr;
> +             CS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
>               log_printf (instance->totemudpu_log_level_warning,
> -                     "Could not set non-blocking operation on token socket: 
> %s\n", error_str);
> +                     "Could not set non-blocking operation on token socket: 
> %s\n", error_ptr);
>               return (-1);
>       }
>  
> @@ -1340,9 +1345,10 @@ static int totemudpu_build_sockets_ip (
>               &recvbuf_size, optlen);
>       if (res == -1) {
>               char error_str[100];
> -             strerror_r (errno, error_str, 100);
> +             const char *error_ptr;
> +             CS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
>               log_printf (instance->totemudpu_log_level_notice,
> -                     "Could not set recvbuf size %s\n", error_str);
> +                     "Could not set recvbuf size %s\n", error_ptr);
>       }
>  
>       return 0;
> @@ -1660,6 +1666,7 @@ int totemudpu_member_add (
>       unsigned int sendbuf_size;
>       unsigned int optlen = sizeof (sendbuf_size);
>       char error_str[100];
> +     const char *error_ptr;
>  
>       new_member = malloc (sizeof (struct totemudpu_member));
>       if (new_member == NULL) {
> @@ -1670,17 +1677,17 @@ int totemudpu_member_add (
>       memcpy (&new_member->member, member, sizeof (struct totem_ip_address));
>       new_member->fd = socket (member->family, SOCK_DGRAM, 0);
>       if (new_member->fd == -1) {
> -             strerror_r (errno, error_str, 100);
> +             CS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
>               log_printf (instance->totemudpu_log_level_warning,
> -                     "Could not create socket for new member: %s\n", 
> error_str);
> +                     "Could not create socket for new member: %s\n", 
> error_ptr);
>               return (-1);
>       }
>       totemip_nosigpipe (new_member->fd);
>       res = fcntl (new_member->fd, F_SETFL, O_NONBLOCK);
>       if (res == -1) {
> -             strerror_r (errno, error_str, 100);
> +             CS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
>               log_printf (instance->totemudpu_log_level_warning,
> -                     "Could not set non-blocking operation on token socket: 
> %s\n", error_str);
> +                     "Could not set non-blocking operation on token socket: 
> %s\n", error_ptr);
>               return (-1);
>       }
>  
> @@ -1692,9 +1699,9 @@ int totemudpu_member_add (
>       res = setsockopt (new_member->fd, SOL_SOCKET, SO_SNDBUF,
>               &sendbuf_size, optlen);
>       if (res == -1) {
> -             strerror_r (errno, error_str, 100);
> +             CS_STRERROR_R (error_ptr, errno, error_str, sizeof(error_str));
>               log_printf (instance->totemudpu_log_level_notice,
> -                     "Could not set sendbuf size %s\n", error_str);
> +                     "Could not set sendbuf size %s\n", error_ptr);
>       }
>       return (0);
>  }
> diff --git a/exec/util.h b/exec/util.h
> index 9e149e5..04e61bf 100644
> --- a/exec/util.h
> +++ b/exec/util.h
> @@ -38,6 +38,18 @@
>  #include <sys/time.h>
>  #include <corosync/corotypes.h>
>  
> +#ifdef COROSYNC_LINUX
> +/* The GNU version of strerror_r returns a (char*) that *must* be used */
> +#define CS_STRERROR_R(out_ptr, errno, buffer, sizeof_buffer) \
> +     out_ptr = strerror_r(errno, buffer, sizeof_buffer);
> +#else
> +/* The XSI-compliant strerror_r() return 0 or -1 (in case the buffer is 
> full) */
> +#define CS_STRERROR_R(out_ptr, errno, buffer, sizeof_buffer) do {    \
> +     strerror_r(errno, buffer, sizeof_buffer);                               
>                 \
> +     out_ptr = buffer;                                                       
>                                         \
> +} while(0)
> +#endif
> +
>  /**
>   * Get the time of day and convert to nanoseconds
>   */
> diff --git a/lcr/uis.c b/lcr/uis.c
> index a124134..a2a5896 100755
> --- a/lcr/uis.c
> +++ b/lcr/uis.c
> @@ -99,8 +99,16 @@ static void uis_lcr_bind (int *server_fd)
>       res = bind (fd, (struct sockaddr *)&un_addr, AIS_SUN_LEN(&un_addr));
>       if (res) {
>               char error_str[100];
> -             strerror_r (errno, error_str, 100);
> -             printf ("Could not bind AF_UNIX: %s\n", error_str);
> +             const char *error_ptr;
> +#ifdef _GNU_SOURCE
> +/* The GNU version of strerror_r returns a (char*) that *must* be used */
> +             error_ptr = strerror_r(errno, error_str, sizeof(error_str));
> +#else
> +/* The XSI-compliant strerror_r() return 0 or -1 (in case the buffer is 
> full) */
> +             strerror_r(errno, error_str, sizeof(error_str));
> +             error_ptr = error_str;
> +#endif
> +             printf ("Could not bind AF_UNIX: %s\n", error_ptr);
>       }
>       listen (fd, SERVER_BACKLOG);
>       *server_fd = fd;
> -- 
> 1.7.5.4
> 
> _______________________________________________
> Openais mailing list
> Openais@lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/openais
_______________________________________________
Openais mailing list
Openais@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/openais

Reply via email to