linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@infradead.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: linux-kernel@vger.kernel.org, Namhyung Kim <namhyung.kim@lge.com>,
	Paul Mackerras <paulus@samba.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 1/7] perf evlist: Restore original errno after open failed
Date: Mon,  5 Mar 2012 12:55:26 -0300	[thread overview]
Message-ID: <1330962932-1796-2-git-send-email-acme@infradead.org> (raw)
In-Reply-To: <1330962932-1796-1-git-send-email-acme@infradead.org>

From: Namhyung Kim <namhyung.kim@lge.com>

If perf_evsel__open() failed, the errno was set and returned properly.

However since the perf_evlist__open() called close() on fd's for all of
evsel x cpu x thread after the failure, the errno was overridden by
other code (EBADF). So the caller of the function ended up seeing
different error message and getting confused.

Fit it by restoring original return value. Because one of caller of the
function is in the python extension, and it uses system errno
internally, it'd be better restoring the original value rather than
using the return value of the function directly, IMHO (i.e. I'm not a
python expert :)

Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1329966816-23175-1-git-send-email-namhyung.kim@lge.com
Signed-off-by: Namhyung Kim <namhyung.kim@lge.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/evlist.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c
index f8da9fa..159263d 100644
--- a/tools/perf/util/evlist.c
+++ b/tools/perf/util/evlist.c
@@ -765,6 +765,7 @@ out_err:
 	list_for_each_entry_reverse(evsel, &evlist->entries, node)
 		perf_evsel__close(evsel, ncpus, nthreads);
 
+	errno = -err;
 	return err;
 }
 
-- 
1.7.9.2.358.g22243


  reply	other threads:[~2012-03-05 15:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-05 15:55 [GIT PULL 0/7] perf/core improvements and fixes Arnaldo Carvalho de Melo
2012-03-05 15:55 ` Arnaldo Carvalho de Melo [this message]
2012-03-05 15:55 ` [PATCH 2/7] perf tools: Add descriptions of missing Makefile arguments Arnaldo Carvalho de Melo
2012-03-05 15:55 ` [PATCH 3/7] perf annotate: Print asm code as blue when source code is displayed Arnaldo Carvalho de Melo
2012-03-05 15:55 ` [PATCH 4/7] perf annotate: Handle lower case key code in annotate_browser__run() Arnaldo Carvalho de Melo
2012-03-05 15:55 ` [PATCH 5/7] perf annotate: Restore title when came back to original symbol Arnaldo Carvalho de Melo
2012-03-05 15:55 ` [PATCH 6/7] perf annotate: Fix help string on tui Arnaldo Carvalho de Melo
2012-03-05 15:55 ` [PATCH 7/7] perf annotate: Add missing newline on error message Arnaldo Carvalho de Melo
2012-03-05 16:02 ` [GIT PULL 0/7] perf/core improvements and fixes Ingo Molnar

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=1330962932-1796-2-git-send-email-acme@infradead.org \
    --to=acme@infradead.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=namhyung.kim@lge.com \
    --cc=paulus@samba.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).