[ovs-dev] [threads 06/11] New function ovs_strerror() as a thread-safe replacement for strerror().

Ben Pfaff blp at nicira.com
Wed Jun 19 21:47:23 UTC 2013


On Wed, Jun 19, 2013 at 05:42:44PM -0400, Ed Maste wrote:
> On 19 June 2013 16:17, Ben Pfaff <blp at nicira.com> wrote:
> > +#if STRERROR_R_CHAR_P
> > +    /* GNU style strerror_r() might return an immutable static string, or it
> > +     * might write and return 'buffer', but in either case we can pass the
> > +     * returned string directly to the caller. */
> > +    s = strerror_r(error, buffer, BUFSIZE);
> > +#else  /* strerror_r() returns an int. */
> > +    s = buffer;
> > +    if (strerror_r(error, buffer, BUFSIZE)) {
> > +        /* strerror_r() is only allowed to fail on ERANGE (because the buffer
> > +         * is too short).  We don't check the actual failure reason because
> > +         * POSIX requires strerror_r() to return the error but old glibc
> > +         * (before 2.13) returns -1 and sets errno. */
> > +        snprintf(buffer, ptb.bufsize, "Unknown error %d", error);
> 
> This one fails to build with:
> 
> lib/util.c:342:26: error: use of undeclared identifier 'ptb'
>         snprintf(buffer, ptb.bufsize, "Unknown error %d", error);
>                          ^

Oops, code from an older revision that I failed to re-test after
changing the implementation pattern.

Thanks, I'll fix that.



More information about the dev mailing list