public inbox for trinity@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Jones <davej@redhat.com>
To: Vince Weaver <vincent.weaver@maine.edu>
Cc: trinity@vger.kernel.org
Subject: Re: [patch] perf_event_open enable sysfs exported events
Date: Tue, 11 Jun 2013 17:32:30 -0400	[thread overview]
Message-ID: <20130611213230.GB17585@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1306111720440.28238@vincent-weaver-1.um.maine.edu>

On Tue, Jun 11, 2013 at 05:24:37PM -0400, Vince Weaver wrote:
 > On Tue, 11 Jun 2013, Dave Jones wrote:
 > 
 > > On Tue, Jun 11, 2013 at 12:33:23AM -0400, Vince Weaver wrote:
 > > 
 > >  > @@ -80,7 +519,7 @@ static int random_event_type(void)
 > >  >  
 > >  >  	int type;
 > >  >  
 > >  > -	switch (rand() % 6) {
 > >  > +	switch (rand() % 8) {
 > >  >  	case 0:
 > >  >  		type = PERF_TYPE_HARDWARE;
 > >  >  		break;
 > >  > @@ -99,6 +538,9 @@ static int random_event_type(void)
 > >  >  	case 5:
 > >  >  		type = PERF_TYPE_BREAKPOINT;
 > >  >  		break;
 > >  > +	case 6:
 > >  > +		type = PERF_TYPE_READ_FROM_SYSFS;
 > >  > +		break;
 > >  >  	default:
 > >  >  		type = rand();
 > >  >  		break;
 > > 
 > > is 8 correct here ? not 7 ?
 > 
 > If you pick 7 then the default case never gets called, correct?  
 > I think that's a minor bug in the existing implementation, the default
 > case was never called.

ah, yeah, I see.

 > Perhaps proper coding convention would be to have the 
 > make-the-type-field-completely-random case be an explicit value and use 
 > the default case only for error handling.

yeah, that's what I've done in a lot of other places (actually BUG() in those cases).
For the most part they're present just to shut up -Wswitch-default, which
has caught a few cases in the past where I've missed an option.
 
 > I should also maybe have the completely-random case be 
 > "completely radom but with preference to values < 256" as that's more
 > likely to trigger actual valid types.

ok, I'll apply what you sent so far. (and hold off on running it through Lindent for now,
you really don't like whitespace huh? ;)

	Dave

  reply	other threads:[~2013-06-11 21:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-11  4:33 [patch] perf_event_open enable sysfs exported events Vince Weaver
2013-06-11 21:05 ` Dave Jones
2013-06-11 21:24   ` Vince Weaver
2013-06-11 21:32     ` Dave Jones [this message]
2013-06-11 22:21       ` Vince Weaver
2013-06-11 22:25         ` Dave Jones
2013-06-13 19:38 ` Tommi Rantala
2013-06-13 19:58   ` Vince Weaver
2013-06-13 20:53     ` Dave Jones
2013-06-13 21:07       ` Vince Weaver
2013-06-13 21:05         ` Dave Jones
2013-06-19 15:27     ` Dave Jones
2013-06-19 16:34       ` Vince Weaver
2013-06-19 16:38         ` Dave Jones
2013-06-19 19:29           ` Vince Weaver

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=20130611213230.GB17585@redhat.com \
    --to=davej@redhat.com \
    --cc=trinity@vger.kernel.org \
    --cc=vincent.weaver@maine.edu \
    /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