From nobody Tue May 7 18:19:38 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+70715+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70715+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=hpe.com ARC-Seal: i=1; a=rsa-sha256; t=1611552034; cv=none; d=zohomail.com; s=zohoarc; b=OOvWlfLayuYKc7m0551RGAA+Bw6B4W7GR7p5JvXAjuXfiL44djMq5Qo9RupJz6XugTcJFwj8GD4yyEwsNOEZw850XxDWFl6nh8Oce5VTdbnBGbHk+txCv+4Iow5RO2z8esbVup/km/JWQQCdcZRpCH2AQYPJLOzTWye0uMT1iA8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611552034; h=Cc:Date:From:List-Id:List-Unsubscribe:Message-ID:Reply-To:Sender:Subject:To; bh=YMJWcwU+5AoK1hJQzlQIla1+t47zxdWkMEpD33jRKbk=; b=EF2Td0DFOyibaETkqBgreh8XK9heja4tpj/nt9B0R+v336RhAvDUE6tnSJf3slkfF1nI6YhqsbOhVdAhAZiVZqhCX/6sgXuF6ARRsKKEnprzVWKzefyqnUS+1KR+uSL6oTsbFdwpMERQF4HanW4HY57c02uj8CHN0q/FBe6BcjY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+70715+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1611552034864798.8504691621466; Sun, 24 Jan 2021 21:20:34 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id QtEbYY1788612xAPyJy1Cpcm; Sun, 24 Jan 2021 21:20:34 -0800 X-Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web08.32528.1611552033741754507 for ; Sun, 24 Jan 2021 21:20:34 -0800 X-Received: from pps.filterd (m0150244.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 10P5I8mU032317; Mon, 25 Jan 2021 05:20:32 GMT X-Received: from g9t5009.houston.hpe.com (g9t5009.houston.hpe.com [15.241.48.73]) by mx0b-002e3701.pphosted.com with ESMTP id 368cf5smug-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Jan 2021 05:20:32 +0000 X-Received: from g9t2301.houston.hpecorp.net (g9t2301.houston.hpecorp.net [16.220.97.129]) by g9t5009.houston.hpe.com (Postfix) with ESMTP id B4B1F71; Mon, 25 Jan 2021 05:20:31 +0000 (UTC) X-Received: from abner-virtual-machine.asiapacific.hpqcorp.net (abner-virtual-machine.asiapacific.hpqcorp.net [15.119.210.153]) by g9t2301.houston.hpecorp.net (Postfix) with ESMTP id 785124B; Mon, 25 Jan 2021 05:20:30 +0000 (UTC) From: "Abner Chang" To: devel@edk2.groups.io Cc: Leif Lindholm , Nickle Wang , Michael D Kinney Subject: [edk2-devel] [PATCH] RedfishPkg/JsonLib: Fix build errors Date: Mon, 25 Jan 2021 12:31:54 +0800 Message-Id: <20210125043154.20645-1-abner.chang@hpe.com> X-HPE-SCL: -1 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,abner.chang@hpe.com X-Gm-Message-State: iHXt22L0s0Ki0wJWRlInzF0Bx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1611552034; bh=WR6rdRDTtmZH08FVtuZXrGzACKPilLuHt+WBCWY8Lf0=; h=Cc:Date:From:Reply-To:Subject:To; b=cJJ2zYD5yO6oGudjuaH2I5o9z7OEfRTHjPKqBWfNcci66cPLvLzCKxBuOY9ojCXlj4F nH8X7l5axkkapD5Pu8mYd7r+IKwT7QysXSZEr62jVslaMfKFzELZYYw/dPbKYrZtXK5On jQDVOVM8ki4QJ7+GRSxp3k6D1WmHf32cQmI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch fixes the build errors when build JsonLib with EDK2 Redfish feature driver. - Add JsonLoadString function to load a NULL terminated-string JSON - json_string_value() in JsonValueGetAsciiString () is removed by accident. Signed-off-by: Abner Chang Cc: Leif Lindholm Cc: Nickle Wang Cc: Michael D Kinney --- RedfishPkg/Library/JsonLib/JsonLib.inf | 5 +++-- RedfishPkg/Include/Library/JsonLib.h | 21 ++++++++++++++++++ RedfishPkg/Library/JsonLib/JsonLib.c | 30 ++++++++++++++++++++++++-- 3 files changed, 52 insertions(+), 4 deletions(-) diff --git a/RedfishPkg/Library/JsonLib/JsonLib.inf b/RedfishPkg/Library/Js= onLib/JsonLib.inf index 48b094a78a..9d52a622e1 100644 --- a/RedfishPkg/Library/JsonLib/JsonLib.inf +++ b/RedfishPkg/Library/JsonLib/JsonLib.inf @@ -75,12 +75,13 @@ # C4244: conversion from type1 to type2, possible loss of data # C4334: 32-bit shift implicitly converted to 64-bit # C4204: nonstandard extension used: non-constant aggregate initializer + # C4706: assignment within conditional expression # # Define macro HAVE_CONFIG_H to include jansson_private_config.h to buil= d. # Undefined _WIN32, WIN64, _MSC_VER macros # On GCC, no error on the unused-function and unused-but-set-variable. # - MSFT:*_*_X64_CC_FLAGS =3D /wd4204 /wd4244 /wd4090 /wd4334 /DHAVE_CONFIG_= H=3D1 /U_WIN32 /UWIN64 /U_MSC_VER - MSFT:*_*_IA32_CC_FLAGS =3D /wd4204 /wd4244 /wd4090 /DHAVE_CONFIG_H=3D1 /= U_WIN32 /UWIN64 /U_MSC_VER + MSFT:*_*_X64_CC_FLAGS =3D /wd4204 /wd4244 /wd4090 /wd4334 /wd4706 /DHAVE= _CONFIG_H=3D1 /U_WIN32 /UWIN64 /U_MSC_VER + MSFT:*_*_IA32_CC_FLAGS =3D /wd4204 /wd4244 /wd4090 /wd4706 /DHAVE_CONFIG= _H=3D1 /U_WIN32 /UWIN64 /U_MSC_VER GCC:*_*_*_CC_FLAGS =3D -Wno-unused-function -Wno-unused-but-set-variable =20 diff --git a/RedfishPkg/Include/Library/JsonLib.h b/RedfishPkg/Include/Libr= ary/JsonLib.h index 3c10f67d27..82ca4bad60 100644 --- a/RedfishPkg/Include/Library/JsonLib.h +++ b/RedfishPkg/Include/Library/JsonLib.h @@ -664,6 +664,27 @@ JsonDumpString ( IN UINTN Flags ); =20 +/** + Convert a string to JSON object. + The function is used to convert a NULL terminated UTF8 encoded string to= a JSON + value. Only object and array represented strings can be converted succes= sfully, + since they are the only valid root values of a JSON text for UEFI usage. + + Real number and number with exponent part are not supportted by UEFI. + + Caller needs to cleanup the root value by calling JsonValueFree(). + + @param[in] String The NULL terminated UTF8 encoded string to co= nvert + + @retval Array JSON value or object JSON value, or NULL when any err= or occurs. + +**/ +EDKII_JSON_VALUE +EFIAPI +JsonLoadString ( + IN CONST CHAR8* String + ); + /** Load JSON from a buffer. =20 diff --git a/RedfishPkg/Library/JsonLib/JsonLib.c b/RedfishPkg/Library/Json= Lib/JsonLib.c index 34ff381aee..1762c6f5af 100644 --- a/RedfishPkg/Library/JsonLib/JsonLib.c +++ b/RedfishPkg/Library/JsonLib/JsonLib.c @@ -430,10 +430,10 @@ JsonValueGetAsciiString ( IN EDKII_JSON_VALUE Json ) { - CHAR8 *AsciiStr; + CONST CHAR8 *AsciiStr; UINTN Index; =20 - AsciiStr =3D (CHAR8 *) ((json_t *) Json); + AsciiStr =3D json_string_value ((json_t *) Json); if (AsciiStr =3D=3D NULL) { return NULL; } @@ -819,6 +819,32 @@ JsonDumpString ( return json_dumps((json_t *)JsonValue, Flags); } =20 +/** + Convert a string to JSON object. + The function is used to convert a NULL terminated UTF8 encoded string to= a JSON + value. Only object and array represented strings can be converted succes= sfully, + since they are the only valid root values of a JSON text for UEFI usage. + + Real number and number with exponent part are not supportted by UEFI. + + Caller needs to cleanup the root value by calling JsonValueFree(). + + @param[in] String The NULL terminated UTF8 encoded string to co= nvert + + @retval Array JSON value or object JSON value, or NULL when any err= or occurs. + +**/ +EDKII_JSON_VALUE +EFIAPI +JsonLoadString ( + IN CONST CHAR8* String + ) +{ + json_error_t JsonError; + + return (EDKII_JSON_VALUE) json_loads ((const char *)String, 0, &JsonErro= r); +} + /** Load JSON from a buffer. =20 --=20 2.17.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#70715): https://edk2.groups.io/g/devel/message/70715 Mute This Topic: https://groups.io/mt/80097450/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-