From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-002e3701.pphosted.com (mx0a-002e3701.pphosted.com [148.163.147.86]) by mx.groups.io with SMTP id smtpd.web09.20161.1611806578514515372 for ; Wed, 27 Jan 2021 20:02:58 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=Q4j19QNh; spf=pass (domain: hpe.com, ip: 148.163.147.86, mailfrom: prvs=0662e9a25a=abner.chang@hpe.com) Received: from pps.filterd (m0150242.ppops.net [127.0.0.1]) by mx0a-002e3701.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 10S3tHjE018116; Thu, 28 Jan 2021 04:02:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hpe.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pps0720; bh=waWfxat0Z15UjupuvWhD6Uyb/95ufp1RM9Et/SBi8WY=; b=Q4j19QNhM/kfB4w8zbT4mOa30s0w/C1/NXeZUQ/MYv+fx6MjiHi/iASMynqNyZHZzjUH BTeqO5m8boKHfuM+7oxbpQntpry7l0iDvDg8GwOdi8NGCe6PUh19xg30b0dGHs/mWRZ+ tLGTAMJjmQvleQP45LBu17rfS4eua4tHw5Nyh947OxybSxhH61lOtBrSDJpQYl5gUBsa Wex2NsVQInzpnXxyD3nDGcwBrj62HLYYDulOHe1vu9oUPjsHDjGtQNVOP/IGxHRUDHzM Ke+AvIQNzO7QO+PPR+aeukuu/tVIVgcZkEBUS2Z/PUMudlZ3MuIY2eIwgoNcUAXA3/rb MA== Received: from g4t3427.houston.hpe.com (g4t3427.houston.hpe.com [15.241.140.73]) by mx0a-002e3701.pphosted.com with ESMTP id 36b5wnf2y1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Jan 2021 04:02:58 +0000 Received: from G9W8453.americas.hpqcorp.net (exchangepmrr1.us.hpecorp.net [16.216.160.211]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by g4t3427.houston.hpe.com (Postfix) with ESMTPS id 3826A57; Thu, 28 Jan 2021 04:02:57 +0000 (UTC) Received: from G2W6309.americas.hpqcorp.net (2002:10c5:4033::10c5:4033) by G9W8453.americas.hpqcorp.net (2002:10d8:a0d3::10d8:a0d3) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 28 Jan 2021 04:02:57 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (15.241.52.11) by G2W6309.americas.hpqcorp.net (16.197.64.51) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Thu, 28 Jan 2021 04:02:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=axtVu0s6N/dGWMg93kFszyfrDAS6L4T+raJlBro/l4joxy8BAd1i2d5O6ggEkYos/IJA9qw2Wrai+BPnhLttZL1vJi9TfqYlEEsN90SL54giL8n2sAEVt11bx24q7ki98hM2QXzE+J0vs6tHkRjIxdzMby3MSaNV/Ea1fv6uCQD+KTCRwVYr9bd/n/Cin4wuia/BD+18mokFZDh3NF4jM9fl42LNFN/bpogZUSP1mC7znzkwCuITvSR3j1ncfA7U4Sinp0A6DN58u1UuoB1A+DWSM2qGxyfOa2tkOMB4BKTx0vqaz29Xcw+50ZoROOqfRI8v/EqHj8TvAVrwVegwaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=N2xfmYuyj8Jq5zx4w4aECELD6IqoyP+NZbvU01lxKRA=; b=O3Xx/W1oxFQ+66ocLQ0rhfKf6zEGdX+ORN8UO40QjuWF5bU7NPd7uJxoPGdSPlGFVNQb11tqvtX2c2hMbEA8icQOh6wrg3bEtL8inhNL9RAoa02dlfcgN/SGDSHvk3lmFekASU7qVErYG9+4vC2xPcAUyAl+sMoRjzAJIkEj5JyLKO/tbsu6R9e7kAe8b9orwBPdwkXXIIPnRjQkXW1iiK4RESPSxgdvcKTx++pg6ceYei5JBn+OAFvP/HdOkU61YRlHA0Q2F9Kkk5UF5VVbeiemswN9wvIUbTQ70XmorFGFIRh7OP0mtMMdmvcX0GXg1E+RtbW4+9oQSDZrFtsTDw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=hpe.com; dmarc=pass action=none header.from=hpe.com; dkim=pass header.d=hpe.com; arc=none Received: from CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7508::16) by CS1PR8401MB0341.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:7509::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.16; Thu, 28 Jan 2021 04:02:55 +0000 Received: from CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM ([fe80::adb6:a875:93ca:b54a]) by CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM ([fe80::adb6:a875:93ca:b54a%12]) with mapi id 15.20.3784.019; Thu, 28 Jan 2021 04:02:54 +0000 From: "Abner Chang" To: "devel@edk2.groups.io" , "leif@nuviainc.com" CC: "Wang, Nickle (HPS SW)" , Michael D Kinney Subject: Re: [edk2-devel] [PATCH] RedfishPkg/JsonLib: Fix build errors Thread-Topic: [edk2-devel] [PATCH] RedfishPkg/JsonLib: Fix build errors Thread-Index: AQHW89a6vRrWezpPEU2lmA06POIB8Ko8a3xQ Date: Thu, 28 Jan 2021 04:02:54 +0000 Message-ID: References: <20210125043154.20645-1-abner.chang@hpe.com> <20210126113034.GO1664@vanye> In-Reply-To: <20210126113034.GO1664@vanye> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=none action=none header.from=hpe.com; x-originating-ip: [16.242.247.131] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 7a361ced-46de-4474-a4a3-08d8c3419731 x-ms-traffictypediagnostic: CS1PR8401MB0341: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:3044; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: H21gZebjnpSvgscnM7CvsLuShC2FgqsUZ3YeO5CEAjQ6hA/+n/EYIMkzm0I5UQDZT6is9qGdy03l7+Z1Ru4OrLEQ5FVXmAjMnQr6kaUCQ7Mnph5wmwHJu1FxRpVBC0fO6594Gt01ugQxNxNHH9lEQ3WI8p4AzuT/1XfcI0C2oWlV0ThPmDVMvWg8o9NxZyXozforu7i/XX/jK13oRJ4yTEkKRzzW5gpYwQCEGp1GlI2rvNRY+hrq8GSa1hxtdSv0Rc1AyGEA2MJoR5aY9JII+SfFbHZK6pz1ob1XPBRP2xqik6Kht3ZbtEfELu2NovsDV3UR251gvSp5FqrDwqnRxCxdlGhliYjMG3KDtaFgI4etOKCiBqt4ijotRIOjPFhv8RiuCoHzwVFjQUwjTh90hSJlpqAFxKACugvWbe7isMyD4v8x79IuU2Rb9326D8ADG50Eann+QOjGC7fgcQl+RVT6ezZkRcZXhLkr8ymKga3oipnlXYt5sNxt9SBcJQN0CtBWmSMysvEGjrLG8xiin/sONomRgYgp9kJ3j1ohzMlvnGRpjmOw7qPKKq5/I2YZSuk+6hEUAzytgd7ufDx++HZVri0OYKowZiC8znhN9BU= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(366004)(39860400002)(346002)(136003)(376002)(396003)(316002)(478600001)(55016002)(52536014)(9686003)(966005)(5660300002)(7696005)(33656002)(86362001)(8676002)(54906003)(66476007)(66556008)(110136005)(76116006)(4326008)(66946007)(53546011)(6506007)(8936002)(83380400001)(2906002)(66446008)(64756008)(71200400001)(19627235002)(26005)(186003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?NUhjIbbBCxOmBMeeRfuw2NY0R75PAP44Bo7YoSbwnh3ad9h8NhjOonpenWyZ?= =?us-ascii?Q?L5TQS1Q5eAMGkqVYnslA/KuqLbAlQDiopusAZglXvP+5BhT4dcSrLrpU+U8s?= =?us-ascii?Q?nec+nvjjKSBbf/TLBFk6x+yvB3xKGbHjmNb8ahmHlvhqVhlHrVZ+QRNVX8JA?= =?us-ascii?Q?iaOw1KidTBIB1W7G+tucbsnVJlMxXX+GgBUhG7gRrbWiIoslx2oxzc9PMx3S?= =?us-ascii?Q?T+InecbkMIN25SqJGMzKtufJuARq/F/plztlKWt9M/G4OW67lRjfXVTR4ZLn?= =?us-ascii?Q?ZVTVM984ca/Ro799CMv29+kWMVvajwena0oXqMIdN84Z/ysRWu25nj5LaTVa?= =?us-ascii?Q?LCgHDnQ7cJIKNI6gbOLZeXTTc8NpJgow7VXiMR9W1Ic6ff+uwRb6FuBoTOJF?= =?us-ascii?Q?ABsVVSBPoqkAeJljQ6LQv81orJLd2+UMzzGtcuvhU/C/9gIBBdu3gYIa/SNh?= =?us-ascii?Q?LWujueFjSkOC2dDDva5LMa/HDRmH9qiYe92rpVsTDezz9S8LjKzHLGzr90mz?= =?us-ascii?Q?LFTLInz9W0WRVF+Qhphy9amS/Z2zsBbA6bTofWc12qbUwjfjHQU/ZYI/H6WY?= =?us-ascii?Q?c+nHAXKNfNfbgMFCc5OhLtQYyf6yc96MOy2vA5yZmS5RkD2ToECDoGWNOEEq?= =?us-ascii?Q?L1Cl2iVmq9iMbdX0m016LRxtnd/0GzraLdoelCa2FhV07RptaRUDake24JsV?= =?us-ascii?Q?b331laJU4RITYT08RhPK0+yLuhhewKoQ82L5owFMPbJCeSGYgbwwZjPQQPhy?= =?us-ascii?Q?hPOhdI7RMUI1bs0MNUnVNG77pWwBA0GlmmKj97fDb/nFxVN/t3KKB7sQk7GA?= =?us-ascii?Q?ND8xzpAtXGEsOqF33k+NnJtbrS6lhiWbSFqmSSX0CPi02WK0WEV9nkdbAFKO?= =?us-ascii?Q?cM7sBgxRfedq0AuV+mXurrPKV+eU4jUWpfS5Kub+XzFfbZVbTSlFWd3iNrTy?= =?us-ascii?Q?s0+F6UojCk5Q8fUCHwC41b4mBOilpB95a4wv4tvck0uRdRV48zl5/OQlFYMS?= =?us-ascii?Q?EHHtOxtpzGYzJxEnGdOPG8k1CDKEH/QgY8tDdE3txzBfegEnAm8C6FNQfMjh?= =?us-ascii?Q?ADZzyuVL?= X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: 7a361ced-46de-4474-a4a3-08d8c3419731 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Jan 2021 04:02:54.9279 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: UInCkf+WYo4uCmFwteQlR7TrEd4wyT6vFsgbjEHeycxUn6gX2lZemhF8hm49/X4NjclXnkTOVG4RaXiQLDb7JQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CS1PR8401MB0341 X-OriginatorOrg: hpe.com X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2021-01-28_01:2021-01-27,2021-01-28 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 impostorscore=0 mlxscore=0 adultscore=0 priorityscore=1501 malwarescore=0 phishscore=0 lowpriorityscore=0 bulkscore=0 spamscore=0 suspectscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101280018 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of > Leif Lindholm > Sent: Tuesday, January 26, 2021 7:31 PM > To: devel@edk2.groups.io; Chang, Abner (HPS SW/FW Technologist) > > Cc: Wang, Nickle (HPS SW) ; Michael D Kinney > > Subject: Re: [edk2-devel] [PATCH] RedfishPkg/JsonLib: Fix build errors >=20 > Hi Abner, >=20 > On Mon, Jan 25, 2021 at 12:31:54 +0800, Abner Chang wrote: > > 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/JsonLib/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 initi= alizer > > + # C4706: assignment within conditional expression > > # > > # Define macro HAVE_CONFIG_H to include jansson_private_config.h to > build. > > # Undefined _WIN32, WIN64, _MSC_VER macros > > # On GCC, no error on the unused-function and unused-but-set-variab= le. > > # > > - 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 >=20 > Urgh, please don't do this. > C4706 is what gives you a warning for accidentally assigning instead of > comparing. It's our last defence against the jeopardy-comparing hordes t= hat > think > if (NULL =3D=3D Ptr) > is a sensible way of writing C. >=20 > What is the actual problem being encountered? That is because we use the macro defined in open source header file, Redfi= shPkg/Library/JsonLib/jansson/src/jansson.h #define json_object_foreach(object, key, value) = \ for (key =3D json_object_iter_key(json_object_iter(object)); = \ key && (value =3D json_object_iter_value(json_object_key_to_iter(= key))); \ key =3D json_object_iter_key( = \ json_object_iter_next(object, json_object_key_to_iter(key)))) >=20 > Beyond that, this will probably be an issue for all architectures, so wh= y add > explicit (identical) workarounds for IA32/X64? I didn't catch this build error on GCC. You may know why? Abner >=20 > Secondly, I understand these changes were added for a single reason "fix > build failures" - but these are two distinct changes, so should be two d= istinct > patches. >=20 > / > Leif >=20 > > GCC:*_*_*_CC_FLAGS =3D -Wno-unused-function > > -Wno-unused-but-set-variable > > > > diff --git a/RedfishPkg/Include/Library/JsonLib.h > > b/RedfishPkg/Include/Library/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 > > ); > > > > +/** > > + 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 > > +successfully, > > + since they are the only valid root values of a JSON text for UEFI u= sage. > > + > > + Real number and number with exponent part are not supportted by UEF= I. > > + > > + Caller needs to cleanup the root value by calling JsonValueFree(). > > + > > + @param[in] String The NULL terminated UTF8 encoded string = to > convert > > + > > + @retval Array JSON value or object JSON value, or NULL when an= y > error occurs. > > + > > +**/ > > +EDKII_JSON_VALUE > > +EFIAPI > > +JsonLoadString ( > > + IN CONST CHAR8* String > > + ); > > + > > /** > > Load JSON from a buffer. > > > > diff --git a/RedfishPkg/Library/JsonLib/JsonLib.c > > b/RedfishPkg/Library/JsonLib/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; > > > > - 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); } > > > > +/** > > + 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 > > +successfully, > > + since they are the only valid root values of a JSON text for UEFI u= sage. > > + > > + Real number and number with exponent part are not supportted by UEF= I. > > + > > + Caller needs to cleanup the root value by calling JsonValueFree(). > > + > > + @param[in] String The NULL terminated UTF8 encoded string = to > convert > > + > > + @retval Array JSON value or object JSON value, or NULL when an= y > error occurs. > > + > > +**/ > > +EDKII_JSON_VALUE > > +EFIAPI > > +JsonLoadString ( > > + IN CONST CHAR8* String > > + ) > > +{ > > + json_error_t JsonError; > > + > > + return (EDKII_JSON_VALUE) json_loads ((const char *)String, 0, > > +&JsonError); } > > + > > /** > > Load JSON from a buffer. > > > > -- > > 2.17.1 > > > > > > > > > > > > >=20 >=20 >=20 >=20