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

Ed Maste emaste at freebsd.org
Wed Jun 19 21:42:44 UTC 2013


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);
                         ^



More information about the dev mailing list