All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ulrich Drepper <drepper@gmail.com>
To: "Kirill A. Shutemov" <kirill@shutemov.name>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] perf: use XSI-complaint version of strerror_r() instead of GNU-specific
Date: Mon, 23 Jul 2012 16:48:22 -0400	[thread overview]
Message-ID: <CAOPLpQdcSw6KGT=odFSAUScd44mUdkYpR6hQM_zg81Y88T=VHg@mail.gmail.com> (raw)
In-Reply-To: <20120723203120.GA25072@shutemov.name>

On Mon, Jul 23, 2012 at 4:31 PM, Kirill A. Shutemov
<kirill@shutemov.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.

  reply	other threads:[~2012-07-23 20:48 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-23 15:00 [PATCH 1/2] perf: fix build error Kirill A. Shutemov
2012-07-23 15:00 ` [PATCH 2/2] perf: use XSI-complaint version of strerror_r() instead of GNU-specific Kirill A. Shutemov
2012-07-23 18:00   ` Ulrich Drepper
2012-07-23 20:31     ` Kirill A. Shutemov
2012-07-23 20:48       ` Ulrich Drepper [this message]
2012-07-23 21:06         ` Kirill A. Shutemov
2012-07-23 22:03           ` Ulrich Drepper
2012-07-24  0:56           ` Namhyung Kim
2012-07-25 19:30           ` [tip:perf/core] perf tools: " tip-bot for Kirill A. Shutemov
2012-07-23 18:02 ` [PATCH 1/2] perf: fix build error Arnaldo Carvalho de Melo
2012-07-23 18:16   ` Kirill A. Shutemov
2012-07-23 18:18     ` Arnaldo Carvalho de Melo
2012-07-23 19:51       ` Kirill A. Shutemov
2012-07-23 21:04         ` Kirill A. Shutemov
2012-07-24  0:38           ` Namhyung Kim
2012-07-25 19:30           ` [tip:perf/core] perf tools: Fix build error with bison 2.6 tip-bot for Kirill A. Shutemov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAOPLpQdcSw6KGT=odFSAUScd44mUdkYpR6hQM_zg81Y88T=VHg@mail.gmail.com' \
    --to=drepper@gmail.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=kirill@shutemov.name \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=paulus@samba.org \
    --subject='Re: [PATCH 2/2] perf: use XSI-complaint version of strerror_r() instead of GNU-specific' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.