From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932516AbcLLKfx (ORCPT ); Mon, 12 Dec 2016 05:35:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34804 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932478AbcLLKfv (ORCPT ); Mon, 12 Dec 2016 05:35:51 -0500 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: David Ahern , Namhyung Kim , Peter Zijlstra , lkml , Ingo Molnar Subject: [PATCH 2/5] perf tools: Use variable instead of repeating lengthy FD macro Date: Mon, 12 Dec 2016 11:35:40 +0100 Message-Id: <1481538943-21874-3-git-send-email-jolsa@kernel.org> In-Reply-To: <1481538943-21874-1-git-send-email-jolsa@kernel.org> References: <1481538943-21874-1-git-send-email-jolsa@kernel.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 12 Dec 2016 10:35:50 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It's more readable and will ease up following patches. Signed-off-by: Jiri Olsa Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/n/tip-0ta7fwl6pb4xnp8b3vddcbpt@git.kernel.org --- tools/perf/util/evsel.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index b2365a63db45..fd61ebd77c26 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -1474,7 +1474,7 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, for (cpu = 0; cpu < cpus->nr; cpu++) { for (thread = 0; thread < nthreads; thread++) { - int group_fd; + int fd, group_fd; if (!evsel->cgrp && !evsel->system_wide) pid = thread_map__pid(threads, thread); @@ -1484,21 +1484,22 @@ static int __perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, pr_debug2("sys_perf_event_open: pid %d cpu %d group_fd %d flags %#lx", pid, cpus->map[cpu], group_fd, flags); - FD(evsel, cpu, thread) = sys_perf_event_open(&evsel->attr, - pid, - cpus->map[cpu], - group_fd, flags); - if (FD(evsel, cpu, thread) < 0) { + fd = sys_perf_event_open(&evsel->attr, pid, cpus->map[cpu], + group_fd, flags); + + FD(evsel, cpu, thread) = fd; + + if (fd < 0) { err = -errno; pr_debug2("\nsys_perf_event_open failed, error %d\n", err); goto try_fallback; } - pr_debug2(" = %d\n", FD(evsel, cpu, thread)); + pr_debug2(" = %d\n", fd); if (evsel->bpf_fd >= 0) { - int evt_fd = FD(evsel, cpu, thread); + int evt_fd = fd; int bpf_fd = evsel->bpf_fd; err = ioctl(evt_fd, -- 2.7.4