From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0706.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe4a::706]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8DA371A1DF5 for ; Tue, 27 Sep 2016 09:03:11 -0700 (PDT) Received: from AT5PR84MB0291.NAMPRD84.PROD.OUTLOOK.COM (10.162.138.25) by AT5PR84MB0291.NAMPRD84.PROD.OUTLOOK.COM (10.162.138.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.639.5; Tue, 27 Sep 2016 16:03:10 +0000 Received: from AT5PR84MB0291.NAMPRD84.PROD.OUTLOOK.COM ([10.162.138.25]) by AT5PR84MB0291.NAMPRD84.PROD.OUTLOOK.COM ([10.162.138.25]) with mapi id 15.01.0639.011; Tue, 27 Sep 2016 16:03:10 +0000 From: "Cohen, Eugene" To: Laszlo Ersek CC: "Kinney, Michael D" , Alexei Fedorov , "edk2-devel@lists.01.org" Thread-Topic: [edk2] What is the right way to print a UINTN? Thread-Index: AdIX/FZUkJ+/GDfSRZe7u7ShyrQtxgADrrkAACt3LCAABK1IAAADDJDA Date: Tue, 27 Sep 2016 16:03:10 +0000 Message-ID: References: <0de4dd03-faa7-1608-9625-369ab5d6e682@redhat.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=eugene@hp.com; x-originating-ip: [15.65.252.13] x-ms-office365-filtering-correlation-id: 6f8efea8-87e0-4eda-a7c7-08d3e6efc72e x-microsoft-exchange-diagnostics: 1; AT5PR84MB0291; 6:Zkaz/MpZjjen2fKUQHk6F+E28DCeCq8JPnEdaAeNEqNvbFOrnrZ3PfB0K6N107YWDa8tTXhIOzr6pkmyZIfZ9w0YYWu4VIJbftfxpP2IOdnMoIe9iZm3oyPJStGtpFqqN98ZTQQvwnwJlwSZRetMhbdDmhtxF5kQydlPAPMMFb5aXNvd1AIlsFkJUqXco759TWQ7z3csOZQHTLpXkIkS5YcXx8L9yvuxuvdxPr3gsReNj8IYi0EgMBBg31XW3o9I65mICbo8GRC3cvtq6RSM4lEFz5b0TgeIW1+tOCFpW08=; 5:2CrcPQEM/h5wEnsbeyYfMBFgD6mLVkT2DWTiglML/Chn1crjGuhhJzhFxSbW2kQfOZVBwGlcAmhoAb+PJHN2XEL7mEI4Z2doeabADzOBz6tct7M3ubmKVESwRMAABEZUI/zOL6pX6s/Z7jnYdionEg==; 24:nOUDzklHkuR6ddUU1dyBTeHG5GRKtfdmRv1KIwpR7BTZXguTl/ee7WU6mVdnjMQe99mwbAqh2jnqF7+08nHbYC76dNMw0kk/oXAjTX3XAUU=; 7:VvuvAsxSXo7GoTrOFce9cuDhetv53m2szVZ2JMZoiVuGCBFqU2xd9/pTXl/Vw+QJQWHs5k6E3p1BHDhcRlNvbB6kcjVmVE60sedPJxQoY98LuNscTK6IpM72MB02uaprWBChv7S/RndAkC3aGQARO7a+ESyLAhVQGUDdIPcXSRJd0uKPPCPAcCuPHoWgL03Bf3b2c9H1WGwGWZrtnYOXNnfVtajWMiUgz1257qv7wheXQOJYqJdl3wZQhgXRiIMeEBs9fAN6/WroA5v8CxF5HowR77BKZp/Ov6kYb/OWbDzOoZKE4d1TE5Uai6i7CcY3 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:AT5PR84MB0291; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001); SRVR:AT5PR84MB0291; BCL:0; PCL:0; RULEID:; SRVR:AT5PR84MB0291; x-forefront-prvs: 007814487B x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(7916002)(189002)(6602003)(199003)(7846002)(66066001)(9686002)(99286002)(97736004)(4326007)(8676002)(3280700002)(6916009)(105586002)(76176999)(81156014)(3846002)(2950100002)(92566002)(6116002)(50986999)(102836003)(3660700001)(74316002)(2906002)(54356999)(586003)(87936001)(81166006)(8936002)(106356001)(10400500002)(7696004)(33656002)(86362001)(77096005)(5660300001)(305945005)(101416001)(2900100001)(110136003)(11100500001)(93886004)(189998001)(7736002)(5002640100001)(122556002)(68736007)(43043002); DIR:OUT; SFP:1102; SCL:1; SRVR:AT5PR84MB0291; H:AT5PR84MB0291.NAMPRD84.PROD.OUTLOOK.COM; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: hp.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: hp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Sep 2016 16:03:10.1096 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: ca7981a2-785a-463d-b82a-3db87dfc3ce6 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AT5PR84MB0291 Subject: Re: What is the right way to print a UINTN? X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Sep 2016 16:03:11 -0000 Content-Language: en-US Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable > Printing UINTN with %x *or* with %d are equally bugs. >=20 > For X64 / AARCH64 / IA64 builds, they are actual bugs (that happen to > work most of the time). Feel free to file a Bugzilla on the extensive usage of this in edk2 [duckin= g and running]. :) =20 > > I'm envisioning having to create a slide in the future for UEFI > > training about the proper use of UINTNs and describing "If you think > > it may exceed 2^32-1 then upcast to UINT64, otherwise don't worry > > about it" and it makes me squirm. >=20 > It makes me squirm too. I think the slide should recommend the > casting > that I proposed. ;) "There is no conversion specifier dedicated to > UINTN; the portable way to print it is to cast it to UINT64, then print > it with %Lx." This is reasonable although I expect to get asked why a lot of the other co= de doesn't adhere to this recommendation. Thanks, Eugene