All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Thomas Richter <tmricht@linux.ibm.com>
Cc: linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	svens@linux.ibm.com, gor@linux.ibm.com, sumanthk@linux.ibm.com,
	hca@linux.ibm.com, Namhyung Kim <namhyung@gmail.com>
Subject: Re: [PATCH v2] perf/s390: Compiler error on s390 for bench/numa.c
Date: Fri, 20 May 2022 11:30:04 -0300	[thread overview]
Message-ID: <Yoel7HCdQr+uSKNA@kernel.org> (raw)
In-Reply-To: <20220520081158.2990006-1-tmricht@linux.ibm.com>

Em Fri, May 20, 2022 at 10:11:58AM +0200, Thomas Richter escreveu:
> The compilation on s390 results in this error:
> 
>  # make DEBUG=y bench/numa.o
>  ...
>  bench/numa.c: In function ‘__bench_numa’:
>  bench/numa.c:1749:81: error: ‘%d’ directive output may be truncated
>              writing between 1 and 11 bytes into a region of size between
>              10 and 20 [-Werror=format-truncation=]
>  1749 |        snprintf(tname, sizeof(tname), "process%d:thread%d", p, t);
>                                                                ^~
>  ...
>  bench/numa.c:1749:64: note: directive argument in the range
>                 [-2147483647, 2147483646]
>  ...
>  #
> 
> The maximum length of the %d replacement is 11 characters because
> of the negative sign.  Therefore extend the array by two more
> characters.
> 
> Output after:
>  # make  DEBUG=y bench/numa.o > /dev/null 2>&1; ll bench/numa.o
>  -rw-r--r-- 1 root root 418320 May 19 09:11 bench/numa.o
>  #
> 
> Fixes: 3aff8ba0a4c9c ("perf bench numa: Avoid possible truncation when using snprintf()")
> Suggested-by: Namhyung Kim <namhyung@gmail.com>



Thanks, applied.

- Arnaldo


> Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
> ---
>  tools/perf/bench/numa.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
> index d5289fa58a4f..20eed1e53f80 100644
> --- a/tools/perf/bench/numa.c
> +++ b/tools/perf/bench/numa.c
> @@ -1740,7 +1740,7 @@ static int __bench_numa(const char *name)
>  		"GB/sec,", "total-speed",	"GB/sec total speed");
>  
>  	if (g->p.show_details >= 2) {
> -		char tname[14 + 2 * 10 + 1];
> +		char tname[14 + 2 * 11 + 1];
>  		struct thread_data *td;
>  		for (p = 0; p < g->p.nr_proc; p++) {
>  			for (t = 0; t < g->p.nr_threads; t++) {
> -- 
> 2.36.1

-- 

- Arnaldo

      reply	other threads:[~2022-05-20 14:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-20  8:11 [PATCH v2] perf/s390: Compiler error on s390 for bench/numa.c Thomas Richter
2022-05-20 14:30 ` Arnaldo Carvalho de Melo [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=Yoel7HCdQr+uSKNA@kernel.org \
    --to=acme@kernel.org \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=namhyung@gmail.com \
    --cc=sumanthk@linux.ibm.com \
    --cc=svens@linux.ibm.com \
    --cc=tmricht@linux.ibm.com \
    /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.