All of lore.kernel.org
 help / color / mirror / Atom feed
From: rnaldo Carvalho de Melo <acme@kernel.org>
To: Colin King <colin.king@canonical.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Stephane Eranian <eranian@google.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf jit: memset variable st using the correct size
Date: Tue, 19 Apr 2016 10:52:21 -0300	[thread overview]
Message-ID: <20160419135221.GF3677@kernel.org> (raw)
In-Reply-To: <20160419134741.GE3677@kernel.org>

Em Tue, Apr 19, 2016 at 10:47:41AM -0300, rnaldo Carvalho de Melo escreveu:
> Em Tue, Apr 19, 2016 at 12:07:18AM +0100, Colin King escreveu:
> > From: Colin Ian King <colin.king@canonical.com>
> > 
> > The current code is memsetting the struct stat variable st with
> > the size of stat (which turns out to be 1 byte) rather than the
> > size of variable sz.
> 
> Thanks, applied.

BTW, its a obvious bug, but I'll add this to the changeset log to
enlighten others ;-)

  [acme@jouet c]$ cc -pedantic sizeof_function.c -o sizeof_function
  sizeof_function.c: In function ‘main’:
  sizeof_function.c:8:46: warning: invalid application of ‘sizeof’ to a function type [-Wpointer-arith]
    printf("sizeof(stat)=%zd, stat=%p\n", sizeof(stat), stat);
                                              ^
  [acme@jouet c]$ ./sizeof_function 
  sizeof(stat)=1, stat=0x40063

As my expectation was for this to return sizeof(void *) :-\

- Arnaldo
 
> - Arnaldo
>  
> > Signed-off-by: Colin Ian King <colin.king@canonical.com>
> > ---
> >  tools/perf/util/jitdump.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/tools/perf/util/jitdump.c b/tools/perf/util/jitdump.c
> > index 52fcef3..86afe96 100644
> > --- a/tools/perf/util/jitdump.c
> > +++ b/tools/perf/util/jitdump.c
> > @@ -412,7 +412,7 @@ static int jit_repipe_code_load(struct jit_buf_desc *jd, union jr_entry *jr)
> >  		return -1;
> >  	}
> >  	if (stat(filename, &st))
> > -		memset(&st, 0, sizeof(stat));
> > +		memset(&st, 0, sizeof(st));
> >  
> >  	event->mmap2.header.type = PERF_RECORD_MMAP2;
> >  	event->mmap2.header.misc = PERF_RECORD_MISC_USER;
> > @@ -500,7 +500,7 @@ static int jit_repipe_code_move(struct jit_buf_desc *jd, union jr_entry *jr)
> >  	size++; /* for \0 */
> >  
> >  	if (stat(filename, &st))
> > -		memset(&st, 0, sizeof(stat));
> > +		memset(&st, 0, sizeof(st));
> >  
> >  	size = PERF_ALIGN(size, sizeof(u64));
> >  
> > -- 
> > 2.7.4

  reply	other threads:[~2016-04-19 13:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-18 23:07 [PATCH] perf jit: memset variable st using the correct size Colin King
2016-04-19 13:47 ` rnaldo Carvalho de Melo
2016-04-19 13:52   ` rnaldo Carvalho de Melo [this message]
2016-04-23 13:04 ` [tip:perf/core] perf jit: memset() variable 'st' " tip-bot for Colin Ian King

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=20160419135221.GF3677@kernel.org \
    --to=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=colin.king@canonical.com \
    --cc=eranian@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.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.