From patchwork Thu Sep 23 06:21:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gowrishankar Muthukrishnan X-Patchwork-Id: 99453 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 28010A0C43; Thu, 23 Sep 2021 08:21:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A1673410DD; Thu, 23 Sep 2021 08:21:55 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id E1753410DC for ; Thu, 23 Sep 2021 08:21:53 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 18MJigvf016921; Wed, 22 Sep 2021 23:21:53 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=wuE4AOCvuMxEhVHCUpIVZp3Nqk93fxb47EevobZ7k/I=; b=kUrOPDymr7NKghhF+XQ9q8N515SONwjG0biJP2UCMxl1PzJVSAhqrN92d8mnRVdPtE+c ZHk4zD+3wzAz7JF3Jg3uT/d614bv5vxf2bSWywH8XJ3B/HneP+inXxKunX5gOuicAUL2 EytAXAJztkEQ65McY/Pk7c6xXWbRneI5GkJZ6q9DlyalYN6v91wl6B7XJ74K171JJEf0 AT+8sewHoHarOA0vKB/zSCECSFoL6ceoNhlG2vogpF24+mvwL4lUrxIMk5vmAvR0KRSt nRW5tLnDt7qX1g7woxpw3DIhKaocaU3ClV3cxUk6pXFHb7sFO5FJP14vozBKAhB834eO 2Q== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com with ESMTP id 3b8awj1tvh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 22 Sep 2021 23:21:52 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Wed, 22 Sep 2021 23:21:51 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Wed, 22 Sep 2021 23:21:51 -0700 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id 77A5C3F703F; Wed, 22 Sep 2021 23:21:49 -0700 (PDT) From: Gowrishankar Muthukrishnan To: CC: , , , Gowrishankar Muthukrishnan Date: Thu, 23 Sep 2021 11:51:46 +0530 Message-ID: <20210923062146.2285376-1-gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210921110243.1919933-1-gmuthukrishn@marvell.com> References: <20210921110243.1919933-1-gmuthukrishn@marvell.com> MIME-Version: 1.0 X-Proofpoint-GUID: 0Oq5x-NpNQseXHkeSTZ-VJLmxqxS0hxJ X-Proofpoint-ORIG-GUID: 0Oq5x-NpNQseXHkeSTZ-VJLmxqxS0hxJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-09-23_02,2021-09-22_01,2020-04-07_01 Subject: [dpdk-dev] [v3] telemetry: fix json output buffer size 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 Sender: "dev" Fix json output buffer size for a single largest value. Also fix compile assertion for the size of output buffer. Fixes: 52af6ccb2b39 ("telemetry: add utility functions for creating JSON") Signed-off-by: Gowrishankar Muthukrishnan --- v3: - use "len" param as buffer size. --- lib/telemetry/telemetry_json.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/telemetry/telemetry_json.h b/lib/telemetry/telemetry_json.h index ad270b9b30..f02a12f5b0 100644 --- a/lib/telemetry/telemetry_json.h +++ b/lib/telemetry/telemetry_json.h @@ -9,6 +9,7 @@ #include #include #include +#include /** * @file @@ -23,13 +24,13 @@ * @internal * Copies a value into a buffer if the buffer has enough available space. * Nothing written to buffer if an overflow ocurs. - * This function is not for use for values larger than 1k. + * This function is not for use for values larger than given buffer length. */ __rte_format_printf(3, 4) static inline int __json_snprintf(char *buf, const int len, const char *format, ...) { - char tmp[1024]; + char tmp[len]; va_list ap; int ret;