All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
To: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Cc: acme@ghostprotocols.net, dsahern@gmail.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] perf tools: Drop strdup in get_filename_for_perf_kvm().
Date: Mon, 16 Dec 2013 17:21:45 -0500	[thread overview]
Message-ID: <52AF7CF9.6010808@cn.fujitsu.com> (raw)
In-Reply-To: <1122029b8eed159852fe6669827b6dff12f81698.1386783950.git.yangds.fnst@cn.fujitsu.com>

Arnaldo or David,
     Could you help to review this patchset. Thanx.

- Yang

On 12/11/2013 12:47 PM, Dongsheng Yang wrote:
> As we need a const char * as a result of get_filename_for_perf_kvm(),
> There is no need to use strdup() for the return value.
>
> This patch drop the strdup() to save memory in get_filename_for_perf_kvm().
>
> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
> ---
>   tools/perf/builtin-kvm.c | 8 +-------
>   tools/perf/util/util.c   | 6 +++---
>   2 files changed, 4 insertions(+), 10 deletions(-)
>
> diff --git a/tools/perf/builtin-kvm.c b/tools/perf/builtin-kvm.c
> index c6fa3cb..03bd946 100644
> --- a/tools/perf/builtin-kvm.c
> +++ b/tools/perf/builtin-kvm.c
> @@ -1712,15 +1712,9 @@ int cmd_kvm(int argc, const char **argv, const char *prefix __maybe_unused)
>   	if (!perf_host)
>   		perf_guest = 1;
>   
> -	if (!file_name) {
> +	if (!file_name)
>   		file_name = get_filename_for_perf_kvm();
>   
> -		if (!file_name) {
> -			pr_err("Failed to allocate memory for filename\n");
> -			return -ENOMEM;
> -		}
> -	}
> -
>   	if (!strncmp(argv[0], "rec", 3))
>   		return __cmd_record(file_name, argc, argv);
>   	else if (!strncmp(argv[0], "rep", 3))
> diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
> index 4a57609..e9cb136 100644
> --- a/tools/perf/util/util.c
> +++ b/tools/perf/util/util.c
> @@ -488,11 +488,11 @@ const char *get_filename_for_perf_kvm(void)
>   	const char *filename;
>   
>   	if (perf_host && !perf_guest)
> -		filename = strdup("perf.data.host");
> +		filename = "perf.data.host";
>   	else if (!perf_host && perf_guest)
> -		filename = strdup("perf.data.guest");
> +		filename = "perf.data.guest";
>   	else
> -		filename = strdup("perf.data.kvm");
> +		filename = "perf.data.kvm";
>   
>   	return filename;
>   }


      parent reply	other threads:[~2013-12-16  9:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-11 17:47 [PATCH 1/2] perf tools: Drop strdup in get_filename_for_perf_kvm() Dongsheng Yang
2013-12-11 17:47 ` [PATCH 2/2] perf tools: Change the default filenames for perf kvm diff to perf.data.xxx and perf.data.xxx.old Dongsheng Yang
2013-12-16 22:21 ` Dongsheng Yang [this message]

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=52AF7CF9.6010808@cn.fujitsu.com \
    --to=yangds.fnst@cn.fujitsu.com \
    --cc=acme@ghostprotocols.net \
    --cc=dsahern@gmail.com \
    --cc=linux-kernel@vger.kernel.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 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.