mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jiri Olsa <jolsa@redhat.com>
To: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>, Jiri Olsa <jolsa@kernel.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Don Zickus <dzickus@redhat.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tools: perf: util: sort.c:  Changed from using strncat to strlcat
Date: Mon, 13 Oct 2014 14:44:02 +0200	[thread overview]
Message-ID: <20141013124401.GA5888@krava.redhat.com> (raw)
In-Reply-To: <1413146435-22202-1-git-send-email-rickard_strandqvist@spectrumdigital.se>

On Sun, Oct 12, 2014 at 10:40:35PM +0200, Rickard Strandqvist wrote:
> Changed from using strncat to strlcat to simplify the code
> 
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
>  tools/perf/util/sort.c |   12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/perf/util/sort.c b/tools/perf/util/sort.c
> index 14e5a03..6e242f0 100644
> --- a/tools/perf/util/sort.c
> +++ b/tools/perf/util/sort.c
> @@ -759,8 +759,7 @@ static int hist_entry__snoop_snprintf(struct hist_entry *he, char *bf,
>  				    size_t size, unsigned int width)
>  {
>  	char out[64];
> -	size_t sz = sizeof(out) - 1; /* -1 for null termination */
> -	size_t i, l = 0;
> +	size_t i;
>  	u64 m = PERF_MEM_SNOOP_NA;
>  
>  	out[0] = '\0';
> @@ -771,12 +770,9 @@ static int hist_entry__snoop_snprintf(struct hist_entry *he, char *bf,
>  	for (i = 0; m && i < NUM_SNOOP_ACCESS; i++, m >>= 1) {
>  		if (!(m & 0x1))
>  			continue;
> -		if (l) {
> -			strcat(out, " or ");
> -			l += 4;
> -		}
> -		strncat(out, snoop_access[i], sz - l);
> -		l += strlen(snoop_access[i]);
> +		if (*out != '\0')
> +			strlcat(out, " or ", sizeof(out));
> +		strlcat(out, snoop_access[i], sizeof(out));

I've got compile error..

[jolsa@krava perf]$ make JOBS=1
  BUILD:   Doing 'make -j1' parallel build
  CC       perf.o
  CC       builtin-annotate.o
  CC       builtin-bench.o
  CC       bench/sched-messaging.o
  CC       bench/sched-pipe.o
  CC       util/sort.o
util/sort.c: In function ‘hist_entry__snoop_snprintf’:
util/sort.c:778:4: error: implicit declaration of function ‘strlcat’ [-Werror=implicit-function-declaration]
    strlcat(out, " or ", sizeof(out));
    ^
util/sort.c:778:4: error: nested extern declaration of ‘strlcat’ [-Werror=nested-externs]
cc1: all warnings being treated as errors
make[1]: *** [util/sort.o] Error 1
make: *** [all] Error 2

jirka

  reply	other threads:[~2014-10-13 12:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-12 20:40 Rickard Strandqvist
2014-10-13 12:44 ` Jiri Olsa [this message]
2014-10-13 20:53   ` Rickard Strandqvist

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=20141013124401.GA5888@krava.redhat.com \
    --to=jolsa@redhat.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=dzickus@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=paulus@samba.org \
    --cc=rickard_strandqvist@spectrumdigital.se \
    /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

Powered by JetHome