[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] strerror_r: avoid compiler warning

From: Bruno Haible
Subject: Re: [PATCH] strerror_r: avoid compiler warning
Date: Wed, 25 May 2011 11:49:18 +0200
User-agent: KMail/1.9.9

Hi Eric,

> On 05/21/2011 12:02 PM, Bruno Haible wrote:
> > Eric Blake wrote:
> >> @@ -48,7 +48,6 @@ AC_DEFUN([gl_FUNC_STRERROR_R],
> >>               [AC_LANG_PROGRAM(
> >>                  [[#include <errno.h>
> >>                    #include <string.h>
> >> -                  int strerror_r (int, char *, size_t);
> >>                  ]],
> >>                  [[int result = 0;
> >>                    char buf[79];
> > 
> > This part doesn't look good to me. The line was meant to provide a 
> > declaration
> > if the system's <string.h> doesn't.
> But we don't get to this part of the m4 file unless we've already passed
> the earlier part about checking if the strerror_r signature complies
> with POSIX.  At which point, either that earlier test already passed
> because the signatures were identical, or it passed because there was no
> declaration at all.


> In the former case, deleting the redundant 
> declaration here makes no difference


> in the latter case, deleting the 
> only declaration here makes compilation fail (which is what we want,
> since that means the system didn't really comply with POSIX after all).

The usual gnulib approach is to provide the declaration only. This is also
what we do in string.in.h:

#  if address@hidden@
_GL_FUNCDECL_SYS (strerror_r, int, (int errnum, char *buf, size_t buflen)
                                   _GL_ARG_NONNULL ((2)));
#  endif

But in the module description modules/strerror_r, we happen to use the
replacement function also when only the declaration is missing, so indeed
in this case it doesn't matter what the "checking whether strerror_r works"
test reports. Probably this was done because on OSF/1 the declaration is

#if defined(_REENTRANT) || defined(_THREAD_SAFE)
                /* _POSIX_REENTRANT_FUNCTIONS */
extern int      strerror_r __((int, char *, int));

and it's risky to mix function pointers with 'int' vs. 'size_t' arguments.

So I withdraw my objection.

In memoriam Witold Pilecki <http://en.wikipedia.org/wiki/Witold_Pilecki>

reply via email to

[Prev in Thread] Current Thread [Next in Thread]