linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Matt Helsley <mhelsley@vmware.com>
Cc: Tzvetomir Stoyanov <tstoyanov@vmware.com>,
	"linux-trace-devel@vger.kernel.org" 
	<linux-trace-devel@vger.kernel.org>
Subject: Re: [PATCH 3/3] tools/lib/traceevent: Implement new traceevent APIs for accessing struct tep_handler fields
Date: Thu, 21 Mar 2019 15:24:50 -0400	[thread overview]
Message-ID: <20190321152450.7489e1d0@gandalf.local.home> (raw)
In-Reply-To: <854FD5EF-691D-4BF2-8A1D-FBF6863B5C19@vmware.com>

On Wed, 20 Mar 2019 16:32:25 +0000
Matt Helsley <mhelsley@vmware.com> wrote:

> > +/**
> > + * tep_check_flag - check the state of event parser flag
> > + * @tep: a handle to the tep_handle
> > + * @flag: flag, or combination of flags to be checked
> > + * can be any combination from enum tep_flag
> > + *
> > + * This checks the state of a flag or combination of flags from enum tep_flag
> > + */
> > +int tep_check_flag(struct tep_handle *tep, enum tep_flag flag)
> > +{
> > +	if (tep)
> > +		return (tep->flags & flag);
> > +	return 0;
> > +}  
> 
> This returns a subset of the flags directly — it doesn’t really check them -- that’s up to the caller.
> So  I’d say this is more of a “getter" than a “checker”.

If we want to be consistent with the kernel, the proper name is "test"

  tep_test_flag()


> 
> If returning a “boolean” is the true intent of the API then it should be:
> 
> return (tep->flags & flag) == flag;

Hmm, this has some side effects that would require documentation. It
makes it only return true if all flags are set, which is not what we
would want.

Since we are only dealing with one flag, (the parameter is an enum, so
multiple flags would not be correct), keeping the return value as is is
the proper approach.

But I'm fine with making the return value a bool and rename it to
"tep_test_flag()"

-- Steve



  parent reply	other threads:[~2019-03-21 19:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-19 11:19 [PATCH 0/3] Few patches, related to libtracevent APIs Tzvetomir Stoyanov
2019-03-19 11:19 ` [PATCH 1/3] tools/lib/traceevent: Change description of few APIs Tzvetomir Stoyanov
2019-03-20 15:48   ` Matt Helsley
2019-03-19 11:19 ` [PATCH 2/3] tools/lib/traceevent: Coding style fixes Tzvetomir Stoyanov
2019-03-20 15:53   ` Matt Helsley
2019-03-19 11:19 ` [PATCH 3/3] tools/lib/traceevent: Implement new traceevent APIs for accessing struct tep_handler fields Tzvetomir Stoyanov
2019-03-20 16:32   ` Matt Helsley
2019-03-21  9:26     ` Tzvetomir Stoyanov
2019-03-21 10:03     ` Tzvetomir Stoyanov
2019-03-21 12:59       ` Steven Rostedt
2019-03-21 19:24     ` Steven Rostedt [this message]
2019-03-21 19:46     ` Steven Rostedt
2019-03-22 11:33       ` Tzvetomir Stoyanov
2019-03-22 12:16         ` Steven Rostedt
2019-03-22 12:49           ` Tzvetomir Stoyanov

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=20190321152450.7489e1d0@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=mhelsley@vmware.com \
    --cc=tstoyanov@vmware.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).