From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754377AbcJEML2 (ORCPT ); Wed, 5 Oct 2016 08:11:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54908 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750774AbcJEML1 (ORCPT ); Wed, 5 Oct 2016 08:11:27 -0400 Date: Wed, 5 Oct 2016 14:11:22 +0200 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , lkml , Don Zickus , Joe Mario , Ingo Molnar , Peter Zijlstra , Namhyung Kim , David Ahern , Andi Kleen Subject: Re: [PATCH 21/57] perf c2c report: Add offset dimension key Message-ID: <20161005121122.GA14067@krava> References: <1474558645-19956-1-git-send-email-jolsa@kernel.org> <1474558645-19956-22-git-send-email-jolsa@kernel.org> <20161005105707.GL7143@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20161005105707.GL7143@kernel.org> User-Agent: Mutt/1.7.0 (2016-08-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 05 Oct 2016 12:11:26 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 05, 2016 at 07:57:07AM -0300, Arnaldo Carvalho de Melo wrote: > Em Thu, Sep 22, 2016 at 05:36:49PM +0200, Jiri Olsa escreveu: > > Adding cacheline offset dimension key support. > > It displays cacheline offset as hex number. > > > > Link: http://lkml.kernel.org/n/tip-m0424ye98lqveg5nopto8qww@git.kernel.org > > Signed-off-by: Jiri Olsa > > --- > > tools/perf/builtin-c2c.c | 35 +++++++++++++++++++++++++++++++++++ > > 1 file changed, 35 insertions(+) > > > > diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c > > index 335c0fd30757..7c52481ec36b 100644 > > --- a/tools/perf/builtin-c2c.c > > +++ b/tools/perf/builtin-c2c.c > > @@ -300,6 +300,32 @@ static int dcacheline_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, > > return snprintf(hpp->buf, hpp->size, "%*s", width, hex_str(addr)); > > } > > > > +static int offset_entry(struct perf_hpp_fmt *fmt, struct perf_hpp *hpp, > > + struct hist_entry *he) > > +{ > > + uint64_t addr = 0; > > + int width = c2c_width(fmt, hpp, he->hists); > > + > > + if (he->mem_info) > > + addr = cl_offset(he->mem_info->daddr.al_addr); > > + > > + return snprintf(hpp->buf, hpp->size, "%*s", width, hex_str(addr)); > > Please don't use snprintf when you actually use the return from this > function, see this part of its man page: > > "If the output was trun‐ cated due to this limit, then the return value > is the number of characters (excluding the terminating null byte) which > would have been written to the final string if enough space had been > available. Thus, a return value of size or more means that the output > was truncated. (See also below under NOTES.)" > > That is why we're using scnprintf where we need to use its return value. > > I'm checking how you use the return value and changing all to scnprintf > instead, ok? ok, always forget this one ;-) thanks, jirka