public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
To: Adrian Hunter <adrian.hunter@intel.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	linux-kernel@vger.kernel.org, David Ahern <dsahern@gmail.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Jiri Olsa <jolsa@redhat.com>, Mike Galbraith <efault@gmx.de>,
	Namhyung Kim <namhyung@gmail.com>,
	Paul Mackerras <paulus@samba.org>,
	Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH 02/11] perf tools: fix path unpopulated in machine__create_modules()
Date: Thu, 19 Sep 2013 11:49:43 -0300	[thread overview]
Message-ID: <20130919144943.GE17742@ghostprotocols.net> (raw)
In-Reply-To: <1379328772-21214-3-git-send-email-adrian.hunter@intel.com>

Em Mon, Sep 16, 2013 at 01:52:43PM +0300, Adrian Hunter escreveu:
> In machine__create_modules() the 'path' char array
> was used in a call to symbol__restricted_filename()
> without always being populated.

Isn't this equivalent and shorter?

[acme@zoo linux]$ git diff
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 933d14f..6188d28 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -792,7 +792,7 @@ static int machine__create_modules(struct machine *machine)
                modules = path;
        }
 
-       if (symbol__restricted_filename(path, "/proc/modules"))
+       if (symbol__restricted_filename(modules, "/proc/modules"))
                return -1;
 
        file = fopen(modules, "r");
[acme@zoo linux]$ 

- Arnaldo

> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
>  tools/perf/util/machine.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> index 933d14f..1ae917c 100644
> --- a/tools/perf/util/machine.c
> +++ b/tools/perf/util/machine.c
> @@ -782,20 +782,17 @@ static int machine__create_modules(struct machine *machine)
>  	size_t n;
>  	FILE *file;
>  	struct map *map;
> -	const char *modules;
>  	char path[PATH_MAX];
>  
>  	if (machine__is_default_guest(machine))
> -		modules = symbol_conf.default_guest_modules;
> -	else {
> -		sprintf(path, "%s/proc/modules", machine->root_dir);
> -		modules = path;
> -	}
> +		strncpy(path, symbol_conf.default_guest_modules, PATH_MAX);
> +	else
> +		snprintf(path, PATH_MAX, "%s/proc/modules", machine->root_dir);
>  
>  	if (symbol__restricted_filename(path, "/proc/modules"))
>  		return -1;
>  
> -	file = fopen(modules, "r");
> +	file = fopen(path, "r");
>  	if (file == NULL)
>  		return -1;
>  
> -- 
> 1.7.11.7

  reply	other threads:[~2013-09-19 14:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-16 10:52 [PATCH 00/11] perf tools: kcore improvements Adrian Hunter
2013-09-16 10:52 ` [PATCH 01/11] perf tools: fix buildid cache handling of kallsyms with kcore Adrian Hunter
2013-09-16 10:52 ` [PATCH 02/11] perf tools: fix path unpopulated in machine__create_modules() Adrian Hunter
2013-09-19 14:49   ` Arnaldo Carvalho de Melo [this message]
2013-09-16 10:52 ` [PATCH 03/11] perf tools: make a separate function to parse /proc/modules Adrian Hunter
2013-09-16 10:52 ` [PATCH 04/11] perf tools: validate kcore module addresses Adrian Hunter
2013-09-16 10:52 ` [PATCH 05/11] perf tools: workaround objdump difficulties with kcore Adrian Hunter
2013-09-16 10:52 ` [PATCH 06/11] perf tools: add map__find_other_map_symbol() Adrian Hunter
2013-09-16 10:52 ` [PATCH 07/11] perf tools: fix annotate_browser__callq() Adrian Hunter
2013-09-16 10:52 ` [PATCH 08/11] perf tools: find kcore symbols on other maps Adrian Hunter
2013-09-16 10:52 ` [PATCH 09/11] perf tools: add copyfile_mode() Adrian Hunter
2013-09-16 10:52 ` [PATCH 10/11] perf buildid-cache: add ability to add kcore to the cache Adrian Hunter
2013-09-16 10:52 ` [PATCH 11/11] perf tools: add ability to find kcore in build-id cache Adrian Hunter

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=20130919144943.GE17742@ghostprotocols.net \
    --to=acme@ghostprotocols.net \
    --cc=a.p.zijlstra@chello.nl \
    --cc=adrian.hunter@intel.com \
    --cc=dsahern@gmail.com \
    --cc=efault@gmx.de \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=namhyung@gmail.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