From nobody Thu Mar 28 20:46:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+59739+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1589806027197984.301326744451; Mon, 18 May 2020 05:47:07 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Ze6xYY1788612x4D8pCkh3Om; Mon, 18 May 2020 05:47:06 -0700 X-Received: from EUR02-HE1-obe.outbound.protection.outlook.com (EUR02-HE1-obe.outbound.protection.outlook.com [40.107.1.44]) by mx.groups.io with SMTP id smtpd.web12.40745.1589806025774564610 for ; Mon, 18 May 2020 05:47:06 -0700 X-Received: from AM6PR01CA0070.eurprd01.prod.exchangelabs.com (2603:10a6:20b:e0::47) by AM7PR08MB5333.eurprd08.prod.outlook.com (2603:10a6:20b:104::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.20; Mon, 18 May 2020 12:47:02 +0000 X-Received: from VE1EUR03FT053.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:e0:cafe::e4) by AM6PR01CA0070.outlook.office365.com (2603:10a6:20b:e0::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.20 via Frontend Transport; Mon, 18 May 2020 12:47:02 +0000 Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+59739+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT053.mail.protection.outlook.com (10.152.19.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.19 via Frontend Transport; Mon, 18 May 2020 12:47:02 +0000 X-Received: ("Tessian outbound 5abcb386707e:v54"); Mon, 18 May 2020 12:47:01 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7cb3f2a5a3d2458c X-CR-MTA-TID: 64aa7808 X-Received: from c03cdac4df9d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id BD05367B-0AB7-42A4-8FA7-8D4ECC4F86EF.1; Mon, 18 May 2020 12:46:56 +0000 X-Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c03cdac4df9d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 May 2020 12:46:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q7AHVasB002bYP75LFXvMI2eHAOFxBjer4cSN/+MYcXl+MBDRjVdaH2LipUUQCdoaa6m4/QHJTqCqLAdhS2Ars+YvqiOkl2W9ssi4hYgxtpjDTJG6gE+ufPtPHvDvgmMlBCu6d0dRyt3gkhrboTYMRMw2YCHdGwFGIsqRB+SuWqpnmZGtLe5PRJfGcXImLCG1AtgjMXMfGeVKwW7dyLgJso6JMRLY4l4x0gXX9ExlOrLlnmyaVxBAoUEnm6g/5h/44Lx8ku89pQ77x3Snezi+ti/j3wCMVVHNaFYUcuMG3ChvEpP/AgRxKEfLmbY/yfsRQO1Kup8Nx3QvuKMA63IYQ== 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=m+tWsp7XIdPdxEANOKgTB3eCBGcCR+hVcDVWWTumWAU=; b=WTrGYIA0zh9It2B8cmmTfMiW5WlFGuQYSlEWBgQPbn9bHrMkXATKCfnZ6K9RvYwcwbJr2rPYSaf6klPvUwEHvhLGXldt5l0gv2EdXtVYaKm6ge/kPDmgzGNRDoST4y01RLaxJh8pd0Rs5pLS0mWIjl14S5AR9YhOFhR315aWzbnHTWyBlqgB7c1YF3TPRAVG+oWXJkVJl/dizJpV/qK/izHriUc4sI/LAg7SQf4NJ44zhEMItuGNLmAIBBdLoJXYHnbkqUAhR/IxHG/g/6dBpXZTvxiFAF5Dh8RrmmmIrEw9rhC7bsfCkvphfB7y73e34/kWmwIgv/qc0xydndX/+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=bestguesspass action=none header.from=arm.com; dkim=none (message not signed); arc=none X-Received: from AM6PR10CA0094.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::35) by AM6PR08MB3765.eurprd08.prod.outlook.com (2603:10a6:20b:8f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.25; Mon, 18 May 2020 12:46:53 +0000 X-Received: from VE1EUR03FT052.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8c:cafe::8a) by AM6PR10CA0094.outlook.office365.com (2603:10a6:209:8c::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.20 via Frontend Transport; Mon, 18 May 2020 12:46:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; X-Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT052.mail.protection.outlook.com (10.152.19.173) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3000.19 via Frontend Transport; Mon, 18 May 2020 12:46:53 +0000 X-Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1415.2; Mon, 18 May 2020 12:46:47 +0000 X-Received: from E107187.Arm.com (10.57.43.215) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Mon, 18 May 2020 12:46:47 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , Subject: [edk2-devel] [PATCH v1-resend 1/2] ArmPlatformPkg: Fix UART divisor warning Date: Mon, 18 May 2020 13:46:45 +0100 Message-ID: <20200518124646.45292-2-sami.mujawar@arm.com> In-Reply-To: <20200518124646.45292-1-sami.mujawar@arm.com> References: <20200518124646.45292-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFTY:;SFS:(4636009)(396003)(39860400002)(376002)(136003)(346002)(46966005)(316002)(86362001)(2616005)(186003)(26005)(966005)(426003)(82310400002)(19627235002)(1076003)(36756003)(7696005)(5660300002)(4326008)(8936002)(47076004)(6916009)(54906003)(44832011)(70206006)(336012)(70586007)(81166007)(2906002)(8676002)(356005)(82740400003)(478600001)(46800400005);DIR:OUT;SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9993796b-a45a-4afe-dac0-08d7fb298fcf X-MS-TrafficTypeDiagnostic: AM6PR08MB3765:|AM7PR08MB5333: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:241;OLM:241; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: TcON8gfTZp9ktUceYiPXu/ImmAnYU3Y7ZuUrjxmwv2qZU3LxnKvm5ONT0YnpCduBVGExzR4/32bDlNK+SF2zFkU5XSjUCy5W6bjKVd/Z3pgUjV3hQ7Nd786jBp22diPyCKipj39FoT7uvw6KsiALBTJy0LWwHE2lJz6y1ndeMqcjXeYvI/uNyCLpf/acBoG/VduLgknSJegJTbTITJwBxxEq1d6HCdRL9Jpbo1yNP2VnTVqsTV9Lk+mzBVvY9e0mu5REllESOQqs+RBq+BqI7dk5Up8kedgil+JWqPVSs3bhX2fY/f0aEZzm6x6a97Qf3/56o7Rlb8Nt7U7+RzkJhNvasBcvnaZQQnRbj/Kblwo6Hhgm6SqESenZO5VIBQyegtOfA+wDeg0AnWUcnCjNyVre5VlGFmNlaEgtvQop/bpVI8b56HcYHr71Hnrp4qaBgGibTjGRrRjHYLhL7pziTQEgJ77Cqo83slK0+GES5JG1zRQ++Bes+u2Ayhe4BehxVzO+r25nIxtQ14a0I8S49s9T0iHF2h4/1mNCVVrnIbe/cyLSiQ4WoUKMC+OS2lS1eCOgx/IDra2fsNuVt5GSNw5u/K6LLx7Ot+sq3EDnpz6WXJCLgLBd7iy4q5iRUihk X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3765 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT053.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: f4413106-9ebd-4094-2cdb-08d7fb298a9f X-Microsoft-Antispam-Message-Info: CKjKwKTLf1l0aiXjM5YHLQHYgy4212f9lkEq86k5PEVJmzOYk2DpiDnYTHmEvzvykvo7yawwBlYvVrejsWKIM925w6V3dwKLbgr8NW4xld7mEouHPyPT43HAlATxE6aa8ZUNQQ+A/sZ704LYGA18aYnijoWGJURXidnqgBTOdFsOaXvxXXwQCAMxkd/YqLz8brfU32Gqtx+Qa6BGGLuLsCp8VyGwMyx8gaHnhq+8y+hFKCUG3GhD+H8FDUpKQT3vLAEp+AL19GK8V4PtX9ORm/niDsPGwVlToszFpP1AkchayZP1DpMA8WOArHvjbrWjIXtb9y1ZxhNknMCogGRsyjBgeuFZVb6SRncK1/RwmBof8apWqVFxbILjjPDi136EcIz2HlNuXWBtSQzpnjzVX2MnFD6r+hHpMQ4yeFsxst0TS85hK8ih2rm0FVwjN6gCH4siBJ0q3A74AdSG/R2B1SZdL3jlIdNb41k+qbzPUhuhykWMtGnYhqwVK1i+BFxx5OQwid0WqXO6JRohIzPwWkpyQ8q2mYZuwKiWzbH+gSpX0beWOAAfW46dVvSmKbRPjHb+AIuc0bhhs5zRSpqfVV3XENDfL4R5S9bzUNYUa5TpDIyQvtEibLt1InA7Mgxo X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2020 12:47:02.0109 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9993796b-a45a-4afe-dac0-08d7fb298fcf X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5333 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,sami.mujawar@arm.com X-Gm-Message-State: DNac2i5Sofx6Q9Bo5kgh6aWIx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1589806026; bh=+MGKIVBbyRszf/pYnxWv9RcFPKozViMyi61p4NX1b64=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=H+Aoq9a9u1GPbUrdpa27p61aoQfzGt28SsM1w3z5oN3ZDYuf2W0B9A6Hj5u+ZxYwoqr MaEj3p4xqoyXMQqnpp1omXwCbyzTDtZeungFAu7jcsdkjXPyZDMtqc+h4OYUsO4c4iknq +z5IPEA9taqc0bijnuIxnCB6Fiu3bfCadfI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The VS2017 compiler reports 'warning C4244: '=3D': conversion from 'UINT64' to 'UINT32', possible loss of data' for the calculation of the UART Divisor value. Fix this warning by adding appropriate typecast and a validation that ensures that the UART divisor value generated does not exceed MAX_UINT32. Signed-off-by: Sami Mujawar Reviewed-by: Alexei Fedorov Reviewed-by: Leif Lindholm Reviewed-by: Philippe Mathieu-Daude --- Notes: v1: - Fix UART divisor warning reported by VS2017 [SAMI] - Resending patch as part of separate series [SAMI] Ref: https://edk2.groups.io/g/devel/message/46279 ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.c b/ArmPlatfo= rmPkg/Library/PL011UartLib/PL011UartLib.c index 801990d9551a638c17d560d4226137b8a3ee47bb..2d3c279cce49304959953ec4a34= b50e09a7d0045 100644 --- a/ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.c +++ b/ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.c @@ -2,7 +2,7 @@ Serial I/O Port library functions with no library constructor/destructor =20 Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
- Copyright (c) 2011 - 2016, ARM Ltd. All rights reserved.
+ Copyright (c) 2011 - 2019, ARM Ltd. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -78,6 +78,7 @@ PL011UartInitializePort ( UINT32 Integer; UINT32 Fractional; UINT32 HardwareFifoDepth; + UINT64 DivisorValue; =20 HardwareFifoDepth =3D (PL011_UARTPID2_VER (MmioRead32 (UartBase + UARTPI= D2)) \ > PL011_VER_R1P4) \ @@ -188,7 +189,12 @@ PL011UartInitializePort ( return RETURN_INVALID_PARAMETER; } =20 - Divisor =3D (UartClkInHz * 4) / *BaudRate; + DivisorValue =3D (((UINT64)UartClkInHz * 4) / *BaudRate); + if (DivisorValue > MAX_UINT32) { + return RETURN_INVALID_PARAMETER; + } + + Divisor =3D (UINT32)DivisorValue; Integer =3D Divisor >> FRACTION_PART_SIZE_IN_BITS; Fractional =3D Divisor & FRACTION_PART_MASK; } --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=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 (#59739): https://edk2.groups.io/g/devel/message/59739 Mute This Topic: https://groups.io/mt/74289924/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- From nobody Thu Mar 28 20:46:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+59740+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1589806028229832.4013901637413; Mon, 18 May 2020 05:47:08 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id vv4AYY1788612xAK8W66nyGN; Mon, 18 May 2020 05:47:07 -0700 X-Received: from EUR02-VE1-obe.outbound.protection.outlook.com (EUR02-VE1-obe.outbound.protection.outlook.com [40.107.2.41]) by mx.groups.io with SMTP id smtpd.web10.41124.1589806027049872148 for ; Mon, 18 May 2020 05:47:07 -0700 X-Received: from AM0PR02CA0103.eurprd02.prod.outlook.com (2603:10a6:208:154::44) by AM0PR08MB4355.eurprd08.prod.outlook.com (2603:10a6:208:13a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.20; Mon, 18 May 2020 12:47:04 +0000 X-Received: from AM5EUR03FT063.eop-EUR03.prod.protection.outlook.com (2603:10a6:208:154:cafe::c9) by AM0PR02CA0103.outlook.office365.com (2603:10a6:208:154::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.20 via Frontend Transport; Mon, 18 May 2020 12:47:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+59740+1787277+3901457@groups.io; helo=web01.groups.io; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT063.mail.protection.outlook.com (10.152.16.226) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.19 via Frontend Transport; Mon, 18 May 2020 12:47:03 +0000 X-Received: ("Tessian outbound e88319d7ccd0:v54"); Mon, 18 May 2020 12:47:03 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: fc9e8d40de35b927 X-CR-MTA-TID: 64aa7808 X-Received: from aece70e5677c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 94049801-D3D9-41F9-B959-BCD7634820B8.1; Mon, 18 May 2020 12:46:58 +0000 X-Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id aece70e5677c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 18 May 2020 12:46:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SKQ6IKIcbMFbq4yYqQyFO3yyZkMEH5vU+so9JqstziOsmTYgdb2e1LUKk/mQVeXlcBRQLrsT0UTaMFg0z5O5mHeKL2GNheQYxsSoOgajfCf2BwESFg1+bdgP+N6O57/AubMdBVFSfsWO8qxSsoMRun7Sz+2uWXqwt+jPcjyxXsvtEOKw6q2+3S6Oz6z5aX/wnh1e+genVcVKjf0/NQuoMUwAbqyT1Y48TlTPR6Fv+Pp80De4XrGk9lgkyk1caEsdTqSoubo29q1Xsq94VNa2AJWqWiDjYWyLmIRLDEGsb2q5QIZN8clfeRD/MHrc4JCxONBcEK2XvtuaPlxAgXdbcw== 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=YrgJpEHUlY4tzwx8n7kP8962dJlzZQMfZpYg2DZhAWg=; b=A4bMDuKoeocEFY3b5RQmP22JUWWADFiEhDWFV8r7/c0vMOYzombBWBqB3a3QbEBBcocj/kV3WE01txgXRmjsLU843Hw1ecaQNXm9+hr+/u5JRixRBRL/wDuyH9c1CksdJvhmhOpC5PFqNr3k173TFpSOyCa8WMRfeg/rp//3e61Rr3VUIvdJE2sFqv3dQl1Q5MfbXld3hhxuxxP8+vDtQuBGyN4KTdU6mkKT2SmtuQPVwhOU509QHmxHscdXFOeFjJqobez3tpeoGOkZqPEpe4A9aKzxnTnBVVi632Dw6DsluLKaD4VJxj5tg19BenZOKZ7/0atUHLsR6+Ccz53Efg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=bestguesspass action=none header.from=arm.com; dkim=none (message not signed); arc=none X-Received: from AM6PR10CA0086.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:8c::27) by AM6PR08MB3416.eurprd08.prod.outlook.com (2603:10a6:20b:50::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.27; Mon, 18 May 2020 12:46:56 +0000 X-Received: from VE1EUR03FT052.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8c:cafe::5) by AM6PR10CA0086.outlook.office365.com (2603:10a6:209:8c::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3000.20 via Frontend Transport; Mon, 18 May 2020 12:46:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; X-Received: from nebula.arm.com (40.67.248.234) by VE1EUR03FT052.mail.protection.outlook.com (10.152.19.173) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3000.19 via Frontend Transport; Mon, 18 May 2020 12:46:55 +0000 X-Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1415.2; Mon, 18 May 2020 12:46:48 +0000 X-Received: from E107187.Arm.com (10.57.43.215) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Mon, 18 May 2020 12:46:47 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , , Subject: [edk2-devel] [PATCH v2 2/2] ArmPlatformPkg: Fix comparison of constants warning Date: Mon, 18 May 2020 13:46:46 +0100 Message-ID: <20200518124646.45292-3-sami.mujawar@arm.com> In-Reply-To: <20200518124646.45292-1-sami.mujawar@arm.com> References: <20200518124646.45292-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFTY:;SFS:(4636009)(39860400002)(376002)(346002)(136003)(396003)(46966005)(70586007)(70206006)(26005)(7696005)(86362001)(316002)(44832011)(2616005)(426003)(19627235002)(186003)(4326008)(82310400002)(81166007)(82740400003)(47076004)(356005)(966005)(1076003)(8676002)(8936002)(478600001)(5660300002)(54906003)(2906002)(336012)(6916009)(36756003)(46800400005);DIR:OUT;SFP:1101; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ce8b2f64-17fb-4b85-78e4-08d7fb2990f4 X-MS-TrafficTypeDiagnostic: AM6PR08MB3416:|AM0PR08MB4355: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 71nfly1u5aGASjYJVcsFdRHPtxzxBA7QyzrNki8rk1HNfMqCg/6EiG7YxuPzvnBNE7IqqA1K6rLG/jpXUmkDmqXL0GTUD5XJlLBEq8+DvzNC06GNoCHRnNtDbs3/OGnCctWemhjqUCf4H4yehXaXOqdnbGzExBL40wqb9c05tfcLqw8dOqOdXYiPYn165o7KWwkz1RVVfCwwto0kLO8ZOt9u25f8fMZZ9vUCdiZYMoLD3S2I9TfQZO3baJVzMYktd8Ss3QWcf9rYCZzOGoLwWtejWFsVsFzajvoQixtNLzfhCUdQK4S3TXJZOLnJx5l9VgzEwiR3U0qXiQEa4oR67dxh/atAr/BcKFx3SNo4Um2WC/TqGrWLr09xMzis5NSqnmeDiWO6a1RTPZHG23tbe2aqgDCr6JtzFOexML8rAmijWAXPlpV2Cmuk9k9TyzuufjYuqE/DaqN1IweW+YGnXBg6zOBPGtIPdbPZ8eotC4tHGvFb9Aw+t3uW2jJvhqp/OBOf6LbQer0UmbER5f+uPUEhcMjFKo9yadDo9d/Bu84tVb5s1G+Hmu5VHeb6Tcx93T4F/jfwADYhjALrLi9U86YSt/1WPVorg009SCD1hmART6syCbqBBqHY+ZOMFkKT X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3416 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT063.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 4820c42d-e85d-4a59-1575-08d7fb298c2d X-Microsoft-Antispam-Message-Info: pi2XIq003PK4pzKTCaVGfHyBRTi/qKmzXYVDhFZ5dBi1xuiq/5ioucJ7WgeqsNXX50wQiWDv9EWg0KcEIgGYDno39H325spGqaZiQc95Is69OwrCMvTSamkvnTUUSmLiMXl6ItMhV0ZnqRDYEqjRw/+4fXUmUiHaRPLJHRa1WN3BBGoq/Q5oPZxpihc8g/4e1FgD+DuIPFLXI5S54SfP77bTniRALBXJFCIPNpDcScFrGDC86kyibqyjAfq/ahBpSdHTD3bmCWz+T61853fw5Gvksh/7k23pvxWf7RWUYmfJ48VDH6rPGzHGIStTYZRi0iRI3uYDTN8DsIXTK683yYyTf7nX+bXVY+GKwhdEagR2eu2apOrqpHpqwzfF8gprUs3QMKuzRROXYonlXoEXmT/83Fs2Sw0kTVEL/L6Kc13gynBLGFodNLqLYOYLWq9bawnFVke/LBYmjI/wd7scNlb/gFKCZ1faHwkwOjNRpmPgxAe1IGcliCVxK3BykWy0jTaRdJFh6tkR0F9kiA4FnA+UxVgwPp+Qm2BogpVCz0wwF2k+lVr4Q8ltkvSHTUNhYdVd8cPbFGH8P2uG/BGSBFTw0LRbXx8zMsUBDUjx2an+7FiXz+yFck7TgU66bwii X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 May 2020 12:47:03.9816 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ce8b2f64-17fb-4b85-78e4-08d7fb2990f4 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4355 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,sami.mujawar@arm.com X-Gm-Message-State: LjG9ppY3mKaFAdDVTpQvgDnUx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1589806027; bh=58i5vWcLga7zESxECtpMwS+zbjFTRadDLFx9vWunjyo=; h=CC:Content-Type:Date:From:Reply-To:Subject:To; b=RyQPsWkNS2C0NYNA566Im9knqT6dSnCmXB0+XYxv7EQVluKYSs5V+o9ZuorxLH0l/BD QcvAjcZHIKPGEiGWtn+p7iHYfI8qgehVhtVOjyM+cRjDpQJAcvGtER0U86jRfMhQ0QcnI mQk6aDXKJfzQKvICH/FzVwAC8neaZBlw+DI= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The VS2017 compiler reports 'warning C6326: potential comparison of a constant with another constant' when a fixed PCD value is compared with a constant value. The faulting code is as marked by '-->' below: --> if (FixedPcdGet32 (PL011UartInteger) !=3D 0) { Integer =3D FixedPcdGet32 (PL011UartInteger); Fractional =3D FixedPcdGet32 (PL011UartFractional); } else { ... The macro FixedPcdGet32 (PL011UartInteger) evaluates to a macro _PCD_VALUE_PL011UartInteger that is defined by the build system to represent the UART Integer value. Therefore, the VS2017 compiler reports the above warning. In this case the warning reported by the Visual Studio compiler does not evaluate to an issue. However, it can be useful to detect potential issues in other scenarios. Other compilers may either be incapable of detecting and reporting comparison with constant warnings or may be good at reducing false positives. So, it is definitely useful to keep this warning enabled, and disabling it case by case is a suitable option. Therefore, disable this warning for Visual studio compilers using the pragma suppress directive that: 'Pushes the current state of the pragma on the stack, disables the specified warning for the next line, and then pops the warning stack so that the pragma state is reset.' Signed-off-by: Sami Mujawar Reviewed-by: Leif Lindholm --- Notes: v2: - Update patch to selectively suppress comparison of [SAMI] constant warning and submit as a separate series. =20 v1: - Fix comparison of constant warning reported by VS2017 [SAMI] - Various feedbacks can be seen at: https://edk2.groups.io/g/devel/topic/32999801#46278 ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.c b/ArmPlatfo= rmPkg/Library/PL011UartLib/PL011UartLib.c index 2d3c279cce49304959953ec4a34b50e09a7d0045..3c915e1e8de22a0b0b4cc46d495= a5a6cbc784013 100644 --- a/ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.c +++ b/ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.c @@ -2,7 +2,7 @@ Serial I/O Port library functions with no library constructor/destructor =20 Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
- Copyright (c) 2011 - 2019, ARM Ltd. All rights reserved.
+ Copyright (c) 2011 - 2020, ARM Ltd. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -174,6 +174,14 @@ PL011UartInitializePort ( // =20 // If PL011 Integer value has been defined then always ignore the BAUD r= ate +#if defined(_MSC_EXTENSIONS) + // Suppress 'warning C6326' reported by Visual Studio compiler using + // the suppress pragma directive that: 'Pushes the current state of + // the pragma on the stack, disables the specified warning for the + // next line, and then pops the warning stack so that the pragma state + // is reset.' +#pragma warning(suppress:6326) +#endif if (FixedPcdGet32 (PL011UartInteger) !=3D 0) { Integer =3D FixedPcdGet32 (PL011UartInteger); Fractional =3D FixedPcdGet32 (PL011UartFractional); --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=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 (#59740): https://edk2.groups.io/g/devel/message/59740 Mute This Topic: https://groups.io/mt/74289925/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-