From patchwork Wed Apr 5 15:44:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 125812 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 6C38E428D4; Wed, 5 Apr 2023 17:44:34 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 473F0427E9; Wed, 5 Apr 2023 17:44:34 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id 63DB941133 for ; Wed, 5 Apr 2023 17:44:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680709473; x=1712245473; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mmfJC07Yk5Du4y0kJIJpE/PA7QDqrWg1Z1GRmzEdht8=; b=Hp2l0KPJ1I4/mfRTRI18OhVY7WEfooh5/G7Sk2NCqIEWfH81I05uZ9ca mt9ewm9uWNz3YC4jCce82ZVk1OHS4O3poS58ND70lOtI6XTpduLO0wKo/ 1g/Fiw47+TTrU6n7NaPA3OKF4Ig/KtmmjaYh2xgzyGYdUTygJmgmR7MiI UYlm0to7ub0UzD+AsSp49QHBjpGzwiZWzHhDH0aT8fJRU6DYe31Z3QKcm O30g1WgCRrYEta0tiKkRWf0nHyNPx7h+Qla9yy+E7l7q8/DpGHbzkw98O MJYSGARHixSK1yzAp/GVZ6XXNGrZxKHL2uOAj+ocRIW3ywP7roz8pGkKa Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10671"; a="339980329" X-IronPort-AV: E=Sophos;i="5.98,321,1673942400"; d="scan'208";a="339980329" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2023 08:44:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10671"; a="686790237" X-IronPort-AV: E=Sophos;i="5.98,321,1673942400"; d="scan'208";a="686790237" Received: from silpixa00401385.ir.intel.com ([10.237.214.40]) by orsmga002.jf.intel.com with ESMTP; 05 Apr 2023 08:44:24 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: ciara.power@intel.com, roretzla@linux.microsoft.com, Bruce Richardson Subject: [PATCH v2 0/5] telemetry: remove variable length arrays Date: Wed, 5 Apr 2023 16:44:09 +0100 Message-Id: <20230405154414.183915-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. 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 | 107 +++++++++++++++++++++++++-------- 3 files changed, 100 insertions(+), 30 deletions(-) --- 2.37.2