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 83EC1428D4; Wed, 5 Apr 2023 17:37:29 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 15AFB41153; Wed, 5 Apr 2023 17:37:29 +0200 (CEST) Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by mails.dpdk.org (Postfix) with ESMTP id A859641133 for ; Wed, 5 Apr 2023 17:37:27 +0200 (CEST) Received: by mail-pj1-f53.google.com with SMTP id lr16-20020a17090b4b9000b0023f187954acso37691055pjb.2 for ; Wed, 05 Apr 2023 08:37:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; t=1680709046; 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=eak50/WBLiT+vsJOcRpC4sLxCwznCSoHZ8G3A1apui4=; b=M/tJKrdgTaVXhH42MzPKXNDdj1suLkCLHmZM12m5QJi9M+1KrGnJHpNgy/dL5sdS7k bArSsaDrTt9JJVvnmU3XoCzquvFe2ctdZUQQrgv9BlwJZZJka63HQvHLWgEmgpifNJu1 H0vqN0Pt03lb9YlB3nUnj/StKI5gxlPKF4YhnvvLkHuiGJ4ooIQho0nKO3zk2sBwKxSo EvdVNK1Bb125WBeJ27GXiYRrxUO9BoA9QAIZgbuQUTbg2vif35stpSkBWP67vSRWAyYi 2i4Tw76chGo9IFVOh6Zxib2VTikAkwIK8kNy2Plxz8B0v/35tOLRDz8H2WahJ1JLsBav HpPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680709046; 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=eak50/WBLiT+vsJOcRpC4sLxCwznCSoHZ8G3A1apui4=; b=NI8rF61H7my00LnJJrsuxxbzpr8UTwtU+ujfmRtjdbMt1WzgDGAe+tUFxkYVjg5XG/ JYnmG3YQJ4fbSvEMfs4iz3L+Z4MEbyUx64VAxx3tjHf6eiXs5QFXejY8CscGB5+mInNR xvnIA8I6J3Evo5ozU/zss+A1QfmJP2MccwnBG5isRqqRjVX6mDNHmGw4+qDe+xvgmhAV rJ7MBilLS6MseFmHkpARB+OH2epvCm7tC/b2xEOSJ+Qo8CxepndQd36SqeyU+OCD6Wvn ol0mf9YuQUg3Trrb9HJKSQkfUB1YM91sRjGH2qqrPSlzdyka/OaMjpC4jnpGc9Baw2o4 oJGQ== X-Gm-Message-State: AAQBX9fhz7CTizyD6hwiMjInqqakbBnB9JO0bwYXA/QZrzr1Ke+dFvcl mmrcH0IBJ6oo8m3K8BaqHnlfPQ== X-Google-Smtp-Source: AKy350Zz0Q0dwuBBQG8ErCiJ6NWErxIvKFKJxBCgy+PMbHsdMXgRWdL0i9Px66WlGXBLplKQjo3Ssg== X-Received: by 2002:a17:902:fa04:b0:1a1:b748:f360 with SMTP id la4-20020a170902fa0400b001a1b748f360mr6076435plb.47.1680709046496; Wed, 05 Apr 2023 08:37:26 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id jj5-20020a170903048500b00196025a34b9sm10402281plb.159.2023.04.05.08.37.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Apr 2023 08:37:26 -0700 (PDT) Date: Wed, 5 Apr 2023 08:37:24 -0700 From: Stephen Hemminger To: Dmitry Kozlyuk Cc: Tyler Retzlaff , Bruce Richardson , 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: <20230405083725.723435e0@hermes.local> In-Reply-To: <20230405183051.274c9cbc@sovereign> 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> <20230405183051.274c9cbc@sovereign> 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 On Wed, 5 Apr 2023 18:30:51 +0300 Dmitry Kozlyuk wrote: > 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. Windows has tools necessary to build asprint equivalent. See: https://github.com/eiszapfen2000/asprintf