From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 64B2BA06C8; Wed, 19 Oct 2022 16:18:17 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 50B2E42BB1; Wed, 19 Oct 2022 16:18:17 +0200 (CEST) Received: from smartserver.smartsharesystems.com (smartserver.smartsharesystems.com [77.243.40.215]) by mails.dpdk.org (Postfix) with ESMTP id 89D5942B6C for ; Wed, 19 Oct 2022 16:18:16 +0200 (CEST) X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: RE: [PATCH] telemetry: support boolean type Date: Wed, 19 Oct 2022 16:18:17 +0200 Message-ID: <98CBD80474FA8B44BF855DF32C47DC35D87418@smartserver.smartshare.dk> In-Reply-To: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH] telemetry: support boolean type Thread-Index: AdjjwWuNjt6jrSmzTuWli/Cl99foQAAA1x0g References: <20221019073702.3948624-1-david.marchand@redhat.com> From: =?iso-8859-1?Q?Morten_Br=F8rup?= To: "Bruce Richardson" , "David Marchand" Cc: , "Ciara Power" X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org > From: Bruce Richardson [mailto:bruce.richardson@intel.com] > Sent: Wednesday, 19 October 2022 15.48 >=20 > 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 > > --- >=20 > 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: >=20 > Reviewed-by: Bruce Richardson > Acked-by: Bruce Richardson [...] > > +/* 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 =3D used - 1; /* strip off final delimiter */ > > + if (used <=3D 2) /* assume empty, since minimum is '[]' */ > > + return __json_snprintf(buf, len, "[%s]", > > + val ? "true" : "false"); > > + > > + ret =3D __json_snprintf(buf + end, len - end, ",%s]", > > + val ? "true" : "false"); >=20 > 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.