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 E2D42428B3; Wed, 5 Apr 2023 03:04:56 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7558840FDF; Wed, 5 Apr 2023 03:04:56 +0200 (CEST) Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by mails.dpdk.org (Postfix) with ESMTP id 678D040DDC for ; Wed, 5 Apr 2023 03:04:54 +0200 (CEST) Received: by mail-pl1-f169.google.com with SMTP id u10so32969150plz.7 for ; Tue, 04 Apr 2023 18:04:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; t=1680656693; 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=qaHk09FxnpaavDEeuR1v5lyOalkpVcyidm0o5RXokiY=; b=f2tuJNx8tF9OgtW7mKst3qHwDgujMOmS45+G/pQUutz3eknofpbnwBF8itkY4PsNKd kfdiMiBa+PiKqjexSii8BcgT7yTq1XBaFmLg0ey2glkCMyMbDkpaOFzoDg+2fnhdE9M8 Zsfz4DBkx428Ztad5MO849M1EVImPS5amsWRjB/8xZ2Kfo5LfzN0U3RZPUXTTCKZkB07 RGb08haFnv+TPzD+KMHF/kFWrTxSNwr7AUgMaW9NghdO4w7MdjUn2FprJWFxG8iHxJwb 3Fs0wUYfXrE6HQusSwUqWUz6MHL61Kf1Vu/b0rMSieNs7pgRX10xsSkHqtNL4lLH7rsl a2vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680656693; 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=qaHk09FxnpaavDEeuR1v5lyOalkpVcyidm0o5RXokiY=; b=WyllyAN+RB6ajugXK7olp1hcfXpxWQWfFdAwXB+tl60nn26c40pVdixR6JyQxglcKL 1ONs+baQhThrMgEQXDcdfxvdjILVULosTfLHofDsKV+lOgIL7VhrKMb1VDZlSKFEDdQG BA43sPukeZW+COvz85dJ5GeV5+lCNgR94QaRs5tf0C/7Oz08pnFs81+IDDU2Mc3k6VNL Y+3O6+XaysHSuG2XmctJY2u8fJmGC4pyh2J0oa/y7muvH0X8d8CvfQ2wovZ65oKnXSiR Ee8+7o0AkjkQHTE1GmEwIXvQ1NAuA0jCfJEepXHhbUM/I/YRXpkvlnXI+tslRqn7dBUv tcYA== X-Gm-Message-State: AAQBX9chbceE1ciM+eRa+BwEixYl0aWroAnq4DOgWmNeej1H7IYVSva5 C3RAkyPAU0YXOaa4X5pVx916aA== X-Google-Smtp-Source: AKy350Y3p4JavXkZnG0ybQ5QpzUcKnosjwuGb9S81LVPHXkgBW1MQCnpzRS7oP2W+vn96q+pdq/WMg== X-Received: by 2002:a17:90b:380d:b0:23f:3:49c5 with SMTP id mq13-20020a17090b380d00b0023f000349c5mr4812195pjb.2.1680656693473; Tue, 04 Apr 2023 18:04:53 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id p22-20020a17090a429600b00232cc61e16bsm153774pjg.35.2023.04.04.18.04.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Apr 2023 18:04:43 -0700 (PDT) Date: Tue, 4 Apr 2023 18:04:32 -0700 From: Stephen Hemminger To: Bruce Richardson Cc: Tyler Retzlaff , , , , Subject: Re: [PATCH 1/2] telemetry: use malloc instead of variable length array Message-ID: <20230404180432.2dc01862@hermes.local> In-Reply-To: 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> 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 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.