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 0DB46428D4; Wed, 5 Apr 2023 17:30:55 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 99D0A41153; Wed, 5 Apr 2023 17:30:54 +0200 (CEST) Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) by mails.dpdk.org (Postfix) with ESMTP id 89DE141133 for ; Wed, 5 Apr 2023 17:30:53 +0200 (CEST) Received: by mail-lf1-f41.google.com with SMTP id bi9so47139309lfb.12 for ; Wed, 05 Apr 2023 08:30:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680708653; x=1683300653; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=tEC1LxEXa0c0etFs9pfINLD7dxxHo/AhVWCtUk8IB14=; b=BuuoyZauvQjTo5vhccR1VqFg8cb8dC+5eptMwYvRF6qOUQyX83tCS9Ctb7mmHAQ+NV 8hQ9a4gSLeR1MkwXqUyPGlXpyDUpjM8C4I9prWkAfo1jGO7FKjrlMeqdvb2BMfbHxG0r x/dtptWUyvUrIo3h7OrAXOcd9GHd2gCKxupg4V47wKOWEJCf/CHpe9e6JNXh3oIl+pUI BY72JAIgmVe9QbSILB2kAS9PhMoOdA4GxBc1mTctYyDWaUmKbN2Ax/sAvkC21+ZalnZV yK4igF+z+iC1R/QCne/bx/8s6IOIz4RfGDIxDZY9xr9HhahV62PePa7AbQ2RGZqmeRXj EmdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680708653; x=1683300653; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=tEC1LxEXa0c0etFs9pfINLD7dxxHo/AhVWCtUk8IB14=; b=OmBQT77dMt4YmuCtzjkzfiCsBSV7MICPNbtvXjUuTCB1zoFuB66V0t7u6n1mYtmjkj y5Qft8MnwQ9hNJeAbiQfXcEhm27ndkADfosl89TgAO2IzpyjKIZUH+ycHVFvshgD7etS k7eGjMUmoj+VCbBexUdnsGWZXReL+uiVR8Rk8Sh/ZoWh4ghERrSEhwgbq7Z/QaO71Kp4 Yhu1b0fGIY2TpoIJnfr/qMioIkNfLNgnJVatoFPHiYocgOToDiS5W29+6T0NGyIB+pU8 ZUuTiOtkvMt3DfCtMDDeMDBCwSCo/QNOUu1ME96XfBUg4GdXM2LaKO9kfxVHlMVEDU4J M1pA== X-Gm-Message-State: AAQBX9ekn0k58Tkada/smrFBkba902MchPKPFlZSRfxWH1hixPsav924 CTi1kB/LpbCCLyFnj/DtcKY= X-Google-Smtp-Source: AKy350Y1fax6dNDupdaAK3Lj1E9MXANBigXfjC6colBvKXjzEHtkkaM3jkSedekOHDEGn7PJUt44yQ== X-Received: by 2002:a05:6512:e84:b0:4eb:4157:5704 with SMTP id bi4-20020a0565120e8400b004eb41575704mr823485lfb.29.1680708652781; Wed, 05 Apr 2023 08:30:52 -0700 (PDT) Received: from sovereign (broadband-109-173-110-33.ip.moscow.rt.ru. [109.173.110.33]) by smtp.gmail.com with ESMTPSA id g1-20020a19ac01000000b004dd7fefd2c8sm2839099lfc.242.2023.04.05.08.30.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 08:30:52 -0700 (PDT) Date: Wed, 5 Apr 2023 18:30:51 +0300 From: Dmitry Kozlyuk To: Tyler Retzlaff Cc: Bruce Richardson , Stephen Hemminger , dev@dpdk.org, ciara.power@intel.com, david.marchand@redhat.com, thomas@monjalon.net Subject: Re: [PATCH 1/2] telemetry: use malloc instead of variable length array Message-ID: <20230405183051.274c9cbc@sovereign> In-Reply-To: <20230405152521.GB28418@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> <20230403131913.0aec54ce@hermes.local> <20230404180432.2dc01862@hermes.local> <20230405152521.GB28418@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 2023-04-05 08:25 (UTC-0700), Tyler Retzlaff: > On Wed, Apr 05, 2023 at 09:54:46AM +0100, Bruce Richardson wrote: > > On Tue, Apr 04, 2023 at 06:04:32PM -0700, Stephen Hemminger wrote: > > > On Tue, 4 Apr 2023 09:47:21 +0100 > > > Bruce Richardson wrote: > > > > > > > My suggestion is to use a combination of these methods. In json_snprintf > > > > check if the input buffer is empty or has only one character in it, and use > > > > method #2 if so. If that's not the case, then fallback to method #1 and do > > > > a double snprintf. > > > > > > > > Make sense? Any other suggestions? > > > > > > Glibc has asprintf which allocates the buffer for you. > > > > Good point, I'll use that in any new implementation. Thanks. > > i imagine there is an equivalent to asprintf for windows but keep in > mind it is not standard C so you'll have to do something conditional. There's eal_asprintf() shim in EAL, we could make it internal to reuse in telemetry.