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 C8AF6428B0; Mon, 3 Apr 2023 19:17:28 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7BB2F40A7E; Mon, 3 Apr 2023 19:17:28 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id B90E8400D6 for ; Mon, 3 Apr 2023 19:17:27 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id D2A57210CB3F; Mon, 3 Apr 2023 10:17:26 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com D2A57210CB3F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1680542246; bh=9Ljxx5bEzSRZsVi6Ocy5CMnJzTHu82T8jQZO/Y62rkg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XcG9fghjYu3+THO0+rAyjr6j5la64K+BEgBlbyn1Mj8qT286QmCtawW2reqXBskXV PAyhTm+h0KDx1jy3TOEJbALgYbi/og8uNTedXLBof9vXCZ0A/kJVSCd8Jq9MIwyWEn l00IvGcwFD3GYTaqDplimXePa5cRl2dOE6ymgNAs= Date: Mon, 3 Apr 2023 10:17:26 -0700 From: Tyler Retzlaff To: dev@dpdk.org Cc: ciara.power@intel.com, bruce.richardson@intel.com, david.marchand@redhat.com, thomas@monjalon.net Subject: Re: [PATCH 1/2] telemetry: use malloc instead of variable length array Message-ID: <20230403171726.GA10756@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1680539424-20255-1-git-send-email-roretzla@linux.microsoft.com> <1680539424-20255-2-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1680539424-20255-2-git-send-email-roretzla@linux.microsoft.com> User-Agent: Mutt/1.5.21 (2010-09-15) 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 On Mon, Apr 03, 2023 at 09:30:23AM -0700, Tyler Retzlaff wrote: > Replace use of variable length array optional standard feature to > improve portability. > > Signed-off-by: Tyler Retzlaff > --- > lib/telemetry/telemetry_json.h | 32 +++++++++++++++++++++++--------- > 1 file changed, 23 insertions(+), 9 deletions(-) > > diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h > index 744bbfe..c375e97 100644 > --- a/lib/telemetry/telemetry_json.h > +++ b/lib/telemetry/telemetry_json.h > @@ -30,18 +30,23 @@ > static inline int > __json_snprintf(char *buf, const int len, const char *format, ...) > { > - char tmp[len]; > + char *tmp = malloc(len); > va_list ap; > - int ret; > + int ret = 0; > + > + if (tmp == NULL) > + return ret; > > va_start(ap, format); > ret = vsnprintf(tmp, sizeof(tmp), format, ap); I mistakenly pushed an old rev, i'll fix this. sorry for the noise.