Re: [PATCH 2/2] perf: use XSI-complaint version of strerror_r()instead of GNU-specific

From: Ulrich Drepper
Date: Mon Jul 23 2012 - 16:48:37 EST


On Mon, Jul 23, 2012 at 4:31 PM, Kirill A. Shutemov
<kirill@xxxxxxxxxxxxx> wrote:
> + const char *err = strerror_r(errnum, buf, buflen);
> +
> + if (err != buf && buflen > 0) {
> + size_t len = strlen(err);
> + char *c = mempcpy(buf, err, min(buflen - 1, len));
> + *c = '\0';
> + }

No need to check for err == NULL. buflen == 0 is a possibility given
the interface but I'd say this is an error and should be tested for at
the beginning of the function and the call should fail or even abort
the program.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/