From patchwork Wed Apr 5 16:03:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 125818 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id CADD5428D4; Wed, 5 Apr 2023 18:04:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3B7C042BB1; Wed, 5 Apr 2023 18:04:38 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mails.dpdk.org (Postfix) with ESMTP id E8BCB427E9 for ; Wed, 5 Apr 2023 18:04:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680710677; x=1712246677; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mdLM/vF+ae3BAxuveH45rUl4ld6HBoqpwv+B6OvrMIY=; b=b4q7MBlnf6ufjBqhMkdVb9i5TavAdAm/3u+pYVSdDPRVpy1aDLobe2sp 1zJRouH26QsowuJLd3Cu5CGyD3VAZbsVk5bh60FaqJ8ed5phovVWFNJeV S5BztN8PApMBNjeMY7A5Px2E2/f4LrhRM3j64eIqWHYLITPHEPVFDVeV9 5u+JfHyN+/x3MptExsjsRO8mDB1GYjWfEOZbmjqwqKDObYHjRyI5/Wm8s 9HO6yLecrh/x/10Scq3PJktJ6OlN/abiaGHt3q6Ccf/Hn/r4fvpmpmMOQ GLw3z4wwBFh6VUNyc2anjiv4s2eyrVyT/FLwynDAfeW6/WCPNXG9Ldsfb A==; X-IronPort-AV: E=McAfee;i="6600,9927,10671"; a="341218569" X-IronPort-AV: E=Sophos;i="5.98,321,1673942400"; d="scan'208";a="341218569" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2023 09:04:16 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10671"; a="830405784" X-IronPort-AV: E=Sophos;i="5.98,321,1673942400"; d="scan'208";a="830405784" Received: from silpixa00401385.ir.intel.com ([10.237.214.40]) by fmsmga001.fm.intel.com with ESMTP; 05 Apr 2023 09:04:14 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: ciara.power@intel.com, roretzla@linux.microsoft.com, Bruce Richardson Subject: [PATCH v3 0/5] telemetry: remove variable length arrays Date: Wed, 5 Apr 2023 17:03:21 +0100 Message-Id: <20230405160326.186921-1-bruce.richardson@intel.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230310181836.162336-1-bruce.richardson@intel.com> References: <20230310181836.162336-1-bruce.richardson@intel.com> MIME-Version: 1.0 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 This patchset introduces a series of changes to remove variable-length arrays from the telemetry code. The first patch replaces a VLA with malloc memory for the serialization of the json objects contained within the main response object, which fixes a crash observed on alpine linux. Subsequent patches rework the json printing code to avoid the use of temporary buffers where possible, or use malloc-allocated memory where not. Based off testing with the unit tests for telemetry, json serialization for the telemetry callbacks should always use the path where a temporary buffer is *not* used, but the allocation-case is kept to ensure that any unexpected edge-cases are covered too. V3: remove use of non-standard asprintf function in patch 2. V2: expand from single fix for Alpine, to general cleanup to remove VLAs Bruce Richardson (5): telemetry: fix autotest failures on Alpine telemetry: remove variable length array in printf fn telemetry: split out body of json string format fn telemetry: rename local variables telemetry: remove VLA in json string format function app/test/test_telemetry_json.c | 2 +- lib/telemetry/telemetry.c | 21 ++++++- lib/telemetry/telemetry_json.h | 111 +++++++++++++++++++++++++-------- 3 files changed, 104 insertions(+), 30 deletions(-) --- 2.37.2