From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752787AbbCVKS6 (ORCPT ); Sun, 22 Mar 2015 06:18:58 -0400 Received: from terminus.zytor.com ([198.137.202.10]:57471 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752077AbbCVKSz (ORCPT ); Sun, 22 Mar 2015 06:18:55 -0400 Date: Sun, 22 Mar 2015 03:18:36 -0700 From: tip-bot for Jiri Olsa Message-ID: Cc: jolsa@kernel.org, namhyung@kernel.org, acme@redhat.com, fweisbec@gmail.com, eranian@google.com, hpa@zytor.com, dsahern@gmail.com, paulus@samba.org, tglx@linutronix.de, a.p.zijlstra@chello.nl, cjashfor@linux.vnet.ibm.com, mingo@kernel.org, adrian.hunter@intel.com, linux-kernel@vger.kernel.org Reply-To: mingo@kernel.org, adrian.hunter@intel.com, paulus@samba.org, dsahern@gmail.com, cjashfor@linux.vnet.ibm.com, a.p.zijlstra@chello.nl, tglx@linutronix.de, linux-kernel@vger.kernel.org, jolsa@kernel.org, fweisbec@gmail.com, eranian@google.com, hpa@zytor.com, namhyung@kernel.org, acme@redhat.com To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Add dsos__addnew function Git-Commit-ID: 701d8d7f861ec36f3bc60d1ddb185cceb7919c79 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 701d8d7f861ec36f3bc60d1ddb185cceb7919c79 Gitweb: http://git.kernel.org/tip/701d8d7f861ec36f3bc60d1ddb185cceb7919c79 Author: Jiri Olsa AuthorDate: Thu, 12 Feb 2015 22:06:09 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Sat, 21 Mar 2015 14:53:42 -0300 perf tools: Add dsos__addnew function Separate the creation of new dso object and its addition to the dsos list. It will be used in following patch. Signed-off-by: Jiri Olsa Acked-by: Namhyung Kim Cc: Adrian Hunter Cc: Corey Ashford Cc: David Ahern Cc: Frederic Weisbecker Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/n/tip-8j43jod97fdt5dwdsushwwae@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/dso.c | 21 ++++++++++++--------- tools/perf/util/dso.h | 1 + 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 3e6863f..7a7c54b 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -1071,21 +1071,24 @@ struct dso *dsos__find(const struct dsos *dsos, const char *name, return dso__find_by_longname(&dsos->root, name); } -struct dso *__dsos__findnew(struct dsos *dsos, const char *name) +struct dso *dsos__addnew(struct dsos *dsos, const char *name) { - struct dso *dso = dsos__find(dsos, name, false); + struct dso *dso = dso__new(name); - if (!dso) { - dso = dso__new(name); - if (dso != NULL) { - dsos__add(dsos, dso); - dso__set_basename(dso); - } + if (dso != NULL) { + dsos__add(dsos, dso); + dso__set_basename(dso); } - return dso; } +struct dso *__dsos__findnew(struct dsos *dsos, const char *name) +{ + struct dso *dso = dsos__find(dsos, name, false); + + return dso ? dso : dsos__addnew(dsos, name); +} + size_t __dsos__fprintf_buildid(struct list_head *head, FILE *fp, bool (skip)(struct dso *dso, int parm), int parm) { diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index 384cd29..3c81d83 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h @@ -264,6 +264,7 @@ struct dso *dso__kernel_findnew(struct machine *machine, const char *name, const char *short_name, int dso_type); void dsos__add(struct dsos *dsos, struct dso *dso); +struct dso *dsos__addnew(struct dsos *dsos, const char *name); struct dso *dsos__find(const struct dsos *dsos, const char *name, bool cmp_short); struct dso *__dsos__findnew(struct dsos *dsos, const char *name);