[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAOPLpQdcSw6KGT=odFSAUScd44mUdkYpR6hQM_zg81Y88T=VHg@mail.gmail.com>
Date: Mon, 23 Jul 2012 16:48:22 -0400
From: Ulrich Drepper <drepper@...il.com>
To: "Kirill A. Shutemov" <kirill@...temov.name>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Paul Mackerras <paulus@...ba.org>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...stprotocols.net>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] perf: use XSI-complaint version of strerror_r()
instead of GNU-specific
On Mon, Jul 23, 2012 at 4:31 PM, Kirill A. Shutemov
<kirill@...temov.name> 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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists