From patchwork Tue Feb 28 17:28:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gowrishankar Muthukrishnan X-Patchwork-Id: 124583 X-Patchwork-Delegate: gakhil@marvell.com 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 6571041D9F; Tue, 28 Feb 2023 18:29:22 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9BF3942B71; Tue, 28 Feb 2023 18:29:15 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 8B324427EE for ; Tue, 28 Feb 2023 18:29:11 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 31SFkDSJ023808; Tue, 28 Feb 2023 09:29:11 -0800 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=P2d1Ob/XZEf0GBq15bKCb46aUmdQPkqg+cs0n/Tk9CM=; b=ezVv8H+6JweyyyQiQiFGNlCRt1tMYnkQcZW9tZSaGytKT6NDMrlhoaKgi2NChWm1Z1z3 GB9Or46Jl5x7hHGZQNMla123+vmU7QZIyYZ0O0xiaO3P2kuK8cKLeIinPWwUWB1IFtfx YAES+9C4G7ZGc5LnyGphwTeWIbXApCABb10LiObWMEGPygJ7A8jpGtSFDTgkImovjAXl Cazo/sUC6tsiq5d36c+tQFbDwk28xq/ucyjjKVCDX3+tfZxeilM/nxTV/wWuABRUzTWQ bu04WkwxP7cs8nu69IbUg74cbdVKpX4owg9pQ9RlzaVMLtcL9+o/4eu9Ieu/s5WF1mw/ Mg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3nyjqty0na-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 28 Feb 2023 09:29:10 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Tue, 28 Feb 2023 09:29:08 -0800 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.42 via Frontend Transport; Tue, 28 Feb 2023 09:29:08 -0800 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id DE8765B6942; Tue, 28 Feb 2023 09:29:06 -0800 (PST) From: Gowrishankar Muthukrishnan To: CC: Anoob Joseph , , Akhil Goyal , Brian Dooley , "Gowrishankar Muthukrishnan" Subject: [v2, 03/10] examples/fips_validation: fix integer parse in test case Date: Tue, 28 Feb 2023 22:58:49 +0530 Message-ID: <23845224ddb99ffcdd68ddbe1ca9e36105334bbb.1677604524.git.gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: gY9v6nC_FBclS-ksuqNhrVXPHwjFqcS- X-Proofpoint-GUID: gY9v6nC_FBclS-ksuqNhrVXPHwjFqcS- X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-02-28_15,2023-02-28_03,2023-02-09_01 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 Parsing integer value in test case vector does not store it because only string was expected. This patch adds handling for integer value as well. Fixes: 58cc98801eb ("examples/fips_validation: add JSON parsing") Signed-off-by: Gowrishankar Muthukrishnan --- examples/fips_validation/fips_validation.c | 29 ++++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/examples/fips_validation/fips_validation.c b/examples/fips_validation/fips_validation.c index f7a6d821ea..d3b6099d73 100644 --- a/examples/fips_validation/fips_validation.c +++ b/examples/fips_validation/fips_validation.c @@ -543,15 +543,28 @@ fips_test_parse_one_json_case(void) for (i = 0; info.callbacks[i].key != NULL; i++) { param = json_object_get(json_info.json_test_case, info.callbacks[i].key); - if (param) { - strcpy(info.one_line_text, json_string_value(param)); - ret = info.callbacks[i].cb( - info.callbacks[i].key, info.one_line_text, - info.callbacks[i].val - ); - if (ret < 0) - return ret; + if (!param) + continue; + + switch (json_typeof(param)) { + case JSON_STRING: + snprintf(info.one_line_text, MAX_LINE_CHAR, "%s", + json_string_value(param)); + break; + + case JSON_INTEGER: + snprintf(info.one_line_text, MAX_LINE_CHAR, "%"JSON_INTEGER_FORMAT, + json_integer_value(param)); + break; + + default: + return -EINVAL; } + + ret = info.callbacks[i].cb(info.callbacks[i].key, info.one_line_text, + info.callbacks[i].val); + if (ret < 0) + return ret; } return 0;