DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Morten Brørup" <mb@smartsharesystems.com>
To: "Bruce Richardson" <bruce.richardson@intel.com>,
	"David Marchand" <david.marchand@redhat.com>
Cc: <dev@dpdk.org>, "Ciara Power" <ciara.power@intel.com>
Subject: RE: [PATCH] telemetry: support boolean type
Date: Wed, 19 Oct 2022 16:18:17 +0200	[thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35D87418@smartserver.smartshare.dk> (raw)
In-Reply-To: <Y1AABobg98qzGTgE@bricha3-MOBL.ger.corp.intel.com>

> From: Bruce Richardson [mailto:bruce.richardson@intel.com]
> Sent: Wednesday, 19 October 2022 15.48
> 
> On Wed, Oct 19, 2022 at 09:37:02AM +0200, David Marchand wrote:
> > Add the boolean type RTE_TEL_BOOL_VAL for values in arrays and dicts.
> >
> > Signed-off-by: David Marchand <david.marchand@redhat.com>
> > ---
> 
> This patch looks pretty good to me. Some very small comments inline
> below.
> One thing I notice is that we are not supporting booleans except as
> part of
> an array or dictionary. Is it likely that we will ever want to have a
> telemetry command that just returns true/false alone? Don't see that
> being
> necessary just yet, so:
> 
> Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>

[...]

> > +/* Appends a boolean into the JSON array in the provided buffer. */
> > +static inline int
> > +rte_tel_json_add_array_bool(char *buf, const int len, const int
> used,
> > +		bool val)
> > +{
> > +	int ret, end = used - 1; /* strip off final delimiter */
> > +	if (used <= 2) /* assume empty, since minimum is '[]' */
> > +		return __json_snprintf(buf, len, "[%s]",
> > +				val ? "true" : "false");
> > +
> > +	ret = __json_snprintf(buf + end, len - end, ",%s]",
> > +			val ? "true" : "false");
> 
> Wonder if it's worthwhile doing a macro for this conditional, since the
> same ternary-operator snippet appears 4 times in this code.

A macro will probably degrade source code readability. Please keep as is.

I considered moving the conditional inside the format string to get rid of the %s. But there is no performance requirement, and it is the exception that it can be done for Booleans (but not integers and other types). So I concluded that the current form is good.


  reply	other threads:[~2022-10-19 14:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-19  7:37 David Marchand
2022-10-19  8:13 ` Morten Brørup
2022-10-19 13:47 ` Bruce Richardson
2022-10-19 14:18   ` Morten Brørup [this message]
2022-10-19 14:28   ` David Marchand
2022-10-19 16:47     ` Bruce Richardson
2022-10-19 18:08       ` Morten Brørup
2022-10-20  9:54 ` Power, Ciara
2022-10-20 11:48   ` David Marchand

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=98CBD80474FA8B44BF855DF32C47DC35D87418@smartserver.smartshare.dk \
    --to=mb@smartsharesystems.com \
    --cc=bruce.richardson@intel.com \
    --cc=ciara.power@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.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 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).