From patchwork Mon Feb 6 14:45:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gowrishankar Muthukrishnan X-Patchwork-Id: 123147 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 BF64B41C12; Mon, 6 Feb 2023 15:46:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7A46C42D5A; Mon, 6 Feb 2023 15:46:26 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id D862142D3F for ; Mon, 6 Feb 2023 15:46:22 +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 31688kgA015844; Mon, 6 Feb 2023 06:46:22 -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=jbXNbYRf1atZ3J+lyAR2r1zANg/WV0SgywLqdUrSNbgPCbeDnj5swr+3nSzXh2KZyqQP zjjN1UnAk8ATpyojY1v8h5mtALUuYayg1uiqkimIPS6bB42SRMpL9NuY9b+X7PYZdQfA aa7efyg0KRphRThz/DoZJ751MSdHIIwF2t7GgtuuLx+E9gKzIK36F5t2pWhyA7lG1ADK sRuIOblkUx8tOxfQRKD01PZQQdr+eOEgxsXC8r9ggeM7aBJ5fuLE1i1G1yyUV+xXZJdM 3CGEA5rgm6o5DU/9+Zjv5K0VIry43QYH02OvHU9kiTQjTu0XR7oEBeDrNj7wz2MbKnSz YQ== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3nhqrtbkch-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 06 Feb 2023 06:46:22 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Mon, 6 Feb 2023 06:46:18 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.42 via Frontend Transport; Mon, 6 Feb 2023 06:46:18 -0800 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id DE2F63F707D; Mon, 6 Feb 2023 06:46:15 -0800 (PST) From: Gowrishankar Muthukrishnan To: CC: Anoob Joseph , , Akhil Goyal , Brian Dooley , "Gowrishankar Muthukrishnan" Subject: [v1, 03/10] examples/fips_validation: fix integer parse in test case Date: Mon, 6 Feb 2023 20:15:55 +0530 Message-ID: <1f5637764dc057ee58ad6354f13296acc3b46fa7.1675693844.git.gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Proofpoint-GUID: sF6gep_sLU0XxfGNhGO-OpF2NfJolm1E X-Proofpoint-ORIG-GUID: sF6gep_sLU0XxfGNhGO-OpF2NfJolm1E X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.930,Hydra:6.0.562,FMLib:17.11.122.1 definitions=2023-02-06_07,2023-02-06_03,2022-06-22_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 Acked-by: Brian Dooley --- 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;