From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web09.31290.1612760710776982558 for ; Sun, 07 Feb 2021 21:05:11 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@hpe.com header.s=pps0720 header.b=b797iKVH; spf=pass (domain: hpe.com, ip: 148.163.143.35, mailfrom: prvs=0673702683=abner.chang@hpe.com) 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 11853FR6002135; Mon, 8 Feb 2021 05:05:10 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=ZcJvF8OaJlV4zoMgaDCRVWizGzatLCFXk/eu3ddEyXI=; b=b797iKVH84VVcQl5Swo4cCUBbwqFUsct/zrVBWDDEEad+MFQEgNSAshW7cSuDiXY9kP5 aMaoaj50R2ndC9TdcyaLkgKMKMnBmcEU/FLMISz6t/Vq8Aiq051+GxtyhN0kZH3FAmbb kEW2USq44HOjnrt9Cq8exDHUFOCAM0BV+fdCN3kRu1WXiP6tNtPd17lrNeK9ih95nn94 G7g4yWUhJH0QM++h7kfcQm7vkjrMqH8OySzzLh9r8NwQZxClbEyR0LAyTvbqAB7LGLQt fO17qwMZTT9GEN4y3q7pymIae9WET2LYo8KU0KmKaH2ffaFgmKEZLZ1IvNArM+HneO10 xw== Received: from g4t3427.houston.hpe.com (g4t3427.houston.hpe.com [15.241.140.73]) by mx0b-002e3701.pphosted.com with ESMTP id 36jr6ejeuq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 Feb 2021 05:05:09 +0000 Received: from G4W9119.americas.hpqcorp.net (g4w9119.houston.hp.com [16.210.20.214]) (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 612AC57; Mon, 8 Feb 2021 05:05:09 +0000 (UTC) Received: from G9W8453.americas.hpqcorp.net (2002:10d8:a0d3::10d8:a0d3) by G4W9119.americas.hpqcorp.net (2002:10d2:14d6::10d2:14d6) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 8 Feb 2021 05:05:08 +0000 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (15.241.52.11) by G9W8453.americas.hpqcorp.net (16.216.160.211) with Microsoft SMTP Server (TLS) id 15.0.1497.2 via Frontend Transport; Mon, 8 Feb 2021 05:05:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z+Q5wI4/esShlIvRTNZKaqn5DViItJD1hRJrrvCKJ34rJ0MsBuL9WXcevvTVM6t78nqiDOC7MhwGbyLoXW72y66Pzhm7539J36mJtfry+f5pgSt2OP4MyTWj6uTuZoFjHCa1i759dl5su5vbZC81ufITGhI9u3JpC15KwEVbaQgWk+FOnc33beqc06K18kM+8BIy3QLzyNujo1/BpPVnAECPbgFEwm+wppqlcjV5ZCDslXwJ2/PN6bJuayftj8HW4l7Jby9zBpIedZUtjIMmyvSpreNpA024wU7urZkIwoMa9+CKu+bz+6IhLuv94VO1afn671sAu7dsJYdykGpz9A== 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=ZcJvF8OaJlV4zoMgaDCRVWizGzatLCFXk/eu3ddEyXI=; b=RV80mPK4GPNfSiovrwPzpOrk6OTNmB6pvTvjk+j+jAvhs1XXHeNjwMMLbZRcFiGZ+fMwCatJGTAa6GSCeqki8PaCyUxMn4MyasnPYcjdS/TSItMMSjC1b+Fj9A9LvLBbTZlKq8Yv8geMxxtzfDgnVnJzkZ7B8RAToXFEB2Q1juk0SFxylU8wp4C57tXKGLq9SSkZgBBc4aFtYL0UyqbdWYTiJKXOXS0cbIdiz6tNQREnSTBvL9QlZ7T5czgE1S9ne6VoiejrTqaF3Bb8gRPZq3bWoz/UFYJ0+PZunCHZq6i06LlY3l/8JZ1QrHcNyIINJ9u6OCmznTRVdLhbXapHiQ== 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 CS1PR8401MB1000.NAMPRD84.PROD.OUTLOOK.COM (2a01:111:e400:750e::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.30; Mon, 8 Feb 2021 05:05:07 +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.3825.030; Mon, 8 Feb 2021 05:05:07 +0000 From: "Abner Chang" To: Leif Lindholm CC: "devel@edk2.groups.io" , "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: AQHW89a6vRrWezpPEU2lmA06POIB8Ko8a3xQgAB7CgCAADR64IAQpvpw Date: Mon, 8 Feb 2021 05:05:07 +0000 Message-ID: References: <20210125043154.20645-1-abner.chang@hpe.com> <20210126113034.GO1664@vanye> <20210128111702.GT1664@vanye> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: nuviainc.com; dkim=none (message not signed) header.d=none;nuviainc.com; 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: ec4ee585-a2b2-4ce5-5e48-08d8cbef1a6a x-ms-traffictypediagnostic: CS1PR8401MB1000: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2201; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: MMMSnUkFstLDnQxqARwSzB7shH/v6LrDrS1vvHiwt9n6UzP0wATh48DdMhZHcMXU4iOvHEdCFVH0dRHblRCpnzisHehj0fFeGGZB7YVs7Nugc30jCY+Rp4VE0lzfiMXGsgtM8F+j68T9eS/KR2p3DZTQPnW3ccIelGH9YLO6qTWYs3bxC4mFUNaEiZywk+1FTJ6UxyEYo2tQecPgwq8OxgIR64P7eBzdCePw8zLE8IfAcgF5/zAlfqKmwPjSy+37lXHjuClSniLHgKwJaZBLPEMDHxrY0qrqkEl2k5q5uw+G/N74rveT5y97+yDhweJwoRhaxJtuMOUsfToNMZeeENSvsPmb5xs7nYi5nWoNCuNQVQdzq/m/aKUUyAhPFPvoYmYQGymtCMzE01ysNCt3oFVf1th793I6kw/0EazVDWHtxbWz+b3nsshrk6gFNnHQxYuqsRlomTum/eQZQbvzLX0TxTc0PobCeveK1DC9HyBTdwUIF0jORyqsp5OZigq7BboGQUOVLEzKHNdAqgI8hw== 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:(396003)(136003)(346002)(366004)(39860400002)(376002)(52536014)(8936002)(83380400001)(186003)(2906002)(71200400001)(4326008)(8676002)(26005)(7696005)(6506007)(9686003)(33656002)(5660300002)(54906003)(86362001)(64756008)(478600001)(316002)(6916009)(55016002)(66556008)(66946007)(76116006)(66476007)(66446008)(53546011);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?3vhNW6VMWlkz68q/ctPIaKq89rRZ1hc7Tijz0eYGNz80+ZZYOsOHTmpCo4EW?= =?us-ascii?Q?QUV7xZq6PqGVCZOsfUA0+BpcriBNuLRcZ1mvD63K/nZee1jzyk7uBUpfr9ci?= =?us-ascii?Q?/uET1mtzFR1DSNL/Y0w1YHTtZuHLBA89gW5JjtOr8WQX8qR21z3laZb/jrin?= =?us-ascii?Q?kTCo2i/FyTNWzH/noQ9P68N4ZPg1od73sB4G8+OopmAlfu/a3yMFKkcQYgDS?= =?us-ascii?Q?8HDjeE73DuacqtIWRUJvREkhLR5CzUAH/RVlF40QvO4bYgOHVyebrS5VIMGD?= =?us-ascii?Q?yJwSWxtVq8CNQgpdjelx80SX0P2WG6UphAfQv6MWL3fn7ST5yEOsiyP5gWtl?= =?us-ascii?Q?VDkKpAQCON6jJAwxIUnO8IcNz+AODdyiDZ25YbQQTjyzyg0dFiEiZt22U3j4?= =?us-ascii?Q?cphZnmvGjdECcLvCdz5t/w3YmpVgsHhN9I1OU/eil80B/x4JCMHF2LYgTdv5?= =?us-ascii?Q?dhoO3lDiR2wVHpAFCKmXDXZbX43cTX5lJ11FCgQAL+mdhvIM99ho93K8GmnR?= =?us-ascii?Q?Rx8xcbaXzk/Xm9Yx/A1N+h0ieXALjee92MYbbB93IrESnivPcJv9Q4G+XIIw?= =?us-ascii?Q?+1pHQn7v149PunykmY86NZS3TRrhf4tto3E7v0Ec5fsnWM2VD7HTW01Go8ft?= =?us-ascii?Q?TvcQjkyitgrjLslOw32dL33tvZZFY6SVDEo9tUAUWnrBzI8K4RW5jkA0klO8?= =?us-ascii?Q?TRDGOiWDgSc7+HCDgZSCmlW1aI8mXo8Na5HTa0hfPtJPXvM3kiH+sSXLNqRr?= =?us-ascii?Q?SqdOM6M8/IjsGvWB/kxuY+t3AUHldioS++JLt6bArDnLGMNnfzw/COSTec67?= =?us-ascii?Q?Xyk/eRLkT/wR/lOP8DvYb4Ug+dvgN6UQT0/AATCr4DnU7gDB69zLsmx/wx2J?= =?us-ascii?Q?5dx1OMBA3ypynw+axutfczaHIcxoh9a8vcWp7ubYZUjkyRQI0m/2Rbaqv9D3?= =?us-ascii?Q?ptjs3rCmDjUj1F+xKqcDz9R04A93SOGjjyBCc00UA9MRvUO9VLroRLWZl47/?= =?us-ascii?Q?heY54gw7/TKm8OdzAF2RumKKG90QYY0ZnmbE5TP9AVTCbjCu6iibrHMf8Dgo?= =?us-ascii?Q?/VdqpadQLJk3/EG1HFUz3LWqTsbGzHCp7NUJf3FyPlJEnJMaISf9xJwmxPAl?= =?us-ascii?Q?FVaOXR8iZoS2huwz/V+Y32J31liDMTqKxzPSRw0qbm9mujlB2B82aWrV883O?= =?us-ascii?Q?UiJqh9bKa62MVVGmNjsLNAxAt0M2HdupTY7ZvJXgf5EpPF1ZSi4RzGGxwo8G?= =?us-ascii?Q?7jIdkTFsPfqzCfpjZbv961m7234KqLlawWlIr4yQlbJyNn1ljMx7lX1fNbOW?= =?us-ascii?Q?RfiDx4HQ53SGXWwBzfP/XKHD?= X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CS1PR8401MB1144.NAMPRD84.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-Network-Message-Id: ec4ee585-a2b2-4ce5-5e48-08d8cbef1a6a X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Feb 2021 05:05:07.2456 (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: 1O2R9v18Gp7VrgHRTlnIoJvq8k38TlGjKpHzx3jZ3nc/7lOzb5kVK2vZlqH9jaepHT9SFHJC/d2Iu7AihLqAAA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CS1PR8401MB1000 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.369,18.0.737 definitions=2021-02-08_01:2021-02-05,2021-02-08 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 clxscore=1015 bulkscore=0 phishscore=0 adultscore=0 lowpriorityscore=0 spamscore=0 impostorscore=0 mlxlogscore=999 malwarescore=0 priorityscore=1501 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2102080034 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: Chang, Abner (HPS SW/FW Technologist) > Sent: Thursday, January 28, 2021 10:31 PM > To: Leif Lindholm > Cc: devel@edk2.groups.io; Wang, Nickle (HPS SW) ; > Michael D Kinney > Subject: RE: [edk2-devel] [PATCH] RedfishPkg/JsonLib: Fix build errors >=20 >=20 >=20 > > -----Original Message----- > > From: Leif Lindholm [mailto:leif@nuviainc.com] > > Sent: Thursday, January 28, 2021 7:17 PM > > To: Chang, Abner (HPS SW/FW Technologist) > > Cc: devel@edk2.groups.io; Wang, Nickle (HPS SW) > ; > > Michael D Kinney > > Subject: Re: [edk2-devel] [PATCH] RedfishPkg/JsonLib: Fix build errors > > > > On Thu, Jan 28, 2021 at 04:02:54 +0000, Chang, Abner (HPS SW/FW > > Technologist) wrote: > > > > > + # 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- > > 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 > > > > > > > > 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 that think > > > > if (NULL =3D=3D Ptr) > > > > is a sensible way of writing C. > > > > > > > > What is the actual problem being encountered? > > > > > > That is because we use the macro defined in open source header file, > > > RedfishPkg/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)))) > > > > Yay, "optimisation" by using preprocessor... > > > > Apart from how this ought to be a helper function: > > - No parentheses around parameters in macro. > > - Setting "value" at each iteration through the loop condition. > > - Slinging parentheses like it's a lisp convention. > > - And it would be worse if they treated the parameters properly. > > > > If we ignore the other issues, the below should be functionally > > equivalent and build on VS without disabling the warning: > > > > for (key =3D json_object_iter_key(json_object_iter(object)); = \ > > key; = \ > > key =3D json_object_iter_key( = \ > > json_object_iter_next(object, json_object_key_to_iter(key))= )) > > { \ > > value =3D json_object_iter_value(json_object_key_to_iter(key)); > > \ > > if (!value) = \ > > break; = \ > > } > > > > Could you try to convince upstream to take the patch? > Sure, I just sent an email to community, hope we can get the feedback soo= n. >=20 > Leif, that may takes time to have this patch to be in upstream (if they a= gree > with it)... I have another PR which is not get merged yet. > This will block our works on edk2, thus I would like to just add build op= tion to > suppress this build error. The build option is only for JsonLib though. D= o you > agree with this? I am working on the PR of your patch for jannson community, however I reali= ze that the patch doesn't work well with the jansson lib. The purpose of th= is macro is to define the for-loop statement, but the "break" in the code b= ody breaks the usage of these macros. Below is one of the use cases of macr= o "json_object_foreach" which is used as the for-loop statement and simple = to use for users to write the code block, In value.c, json_object_foreach(other, key, value) { json_t *v =3D json_object_get(object, key); if (json_is_object(v) && json_is_object(value)) { if (do_object_update_recursive(v, value, parents)) { res =3D -1; break; } } else { if (json_object_set_nocheck(object, key, value)) { res =3D -1; break; } } } I would just keep these macros and the source code which uses these macros = unchanged. Use the build option to ignore the warning message on VS for the= open source jansson lib. Regards, Abner >=20 > Thanks > Abner >=20 > > > > > > Beyond that, this will probably be an issue for all architectures, > > > > so why add explicit (identical) workarounds for IA32/X64? > > > > > > I didn't catch this build error on GCC. You may know why? > > > > Ugh. > > This is because (for whatever reason), both clang and GCC suppress > > this warning if you add parentheses around the assignment. VS does not. > > > > / > > Leif