From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-in6.apple.com (mail-out6.apple.com [17.151.62.28]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B055B1A1DF5 for ; Tue, 27 Sep 2016 09:47:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; d=apple.com; s=mailout2048s; c=relaxed/simple; q=dns/txt; i=@apple.com; t=1474994833; x=2338908433; h=From:Sender:Reply-To:Subject:Date:Message-id:To:Cc:MIME-version:Content-type: Content-transfer-encoding:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-reply-to:References:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=1+PqVeacWPYankhasx4IQWYVJmaWyho1nKqqZHqV68M=; b=wd2Rfr4TNZU2fjwVcWw5wsBmotzpDvIHqnvNAu3ViexUHvIcHUa5fe1X/fey3A8Z RXXQ583yZeP+FmMXCq6wG8QvMCbTv3TZ0XQz6CidjVnsV5yL3+b+mXqu+eUF4cHF yHlBgXIbrKFOT5rEJDI1VPHSiV20ROpkIHecmgFV2yAm1x7iHTDCjRfMHaHixj0f hiWELyhx/LAGaRPTQSq4Jgsv5PzW2tXsZkvHKTfbQwyxhZa+vmQCR7b8VtnGSkco zJ1tA8sUGycIx2mady0zMQy6DjTLWIo0l/ERThm3d0L2yfQbZWp6OiOsZj8cUXGC rDY82kcRPh+tRJDhcqLMxg==; Received: from relay5.apple.com (relay5.apple.com [17.128.113.88]) by mail-in6.apple.com (Apple Secure Mail Relay) with SMTP id CB.AA.07752.192AAE75; Tue, 27 Sep 2016 09:47:13 -0700 (PDT) X-AuditID: 11973e15-f798f6d000001e48-6f-57eaa29135cf Received: from nwk-mmpp-sz11.apple.com (nwk-mmpp-sz11.apple.com [17.128.115.155]) by relay5.apple.com (Apple SCV relay) with SMTP id 22.5C.27929.192AAE75; Tue, 27 Sep 2016 09:47:13 -0700 (PDT) MIME-version: 1.0 Received: from da0601a-dhcp143.apple.com ([17.226.15.143]) by nwk-mmpp-sz11.apple.com (Oracle Communications Messaging Server 8.0.1.1.0 64bit (built Jun 15 2016)) with ESMTPSA id <0OE600E3U9AOPF90@nwk-mmpp-sz11.apple.com>; Tue, 27 Sep 2016 09:47:13 -0700 (PDT) Sender: afish@apple.com From: Andrew Fish In-reply-to: Date: Tue, 27 Sep 2016 09:47:12 -0700 Cc: Laszlo Ersek , Mike Kinney , Alexei Fedorov , "edk2-devel@lists.01.org" Message-id: References: <0de4dd03-faa7-1608-9625-369ab5d6e682@redhat.com> To: Eugene Cohen X-Mailer: Apple Mail (2.3226) X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrKLMWRmVeSWpSXmKPExsUi2FAYoTtx0atwg1UfeCwOP4uxWLfnG7tF 6+c3TBbLju1gsejo+MfkwOqxZt4aRo9d23YyeSze85LJY9KFx8we7/ddZQtgjeKySUnNySxL LdK3S+DKuL9tFUvBBe6KPV3nGRsYZ3J2MXJySAiYSPz5tpMFwhaTuHBvPVsXIxeHkMBeRolT N+8ywRSt6jjBCJE4xCjxavZkdpAEr4CgxI/J94C6OTiYBeQlDp6XBQkzC2hJfH/UygJR38Mk 8fNqJyNIQlhAXOLdmU3MELa1xOKZH1lBbDYBZYkV8z+AzeQUiJeYc/YLG4jNIqAqMfnGRyaQ QcwC6xklLu5vgFpsI7Hh+B12iA1vmCQO9i4BmyQioCDxpuMIE8hFEgKyErN/eYHUSAg8ZpP4 +Wcn+wRGkVlIDp+FcPgsJIcvYGRexSiUm5iZo5uZZ6aXWFCQk6qXnJ+7iREUL9PtRHcwnlll dYhRgINRiYeXoehVuBBrYllxZe4hRmkOFiVx3v/VT8OFBNITS1KzU1MLUovii0pzUosPMTJx cEo1MAp+s8zsM31ltlbiRK/Dd8bjKlbfnu47/MC6rXeG+rFtXZlRfvHFVyKO7Z4m7a/60L7p Kl/ZZf2rZ/1rAyWu9u74ta1POjTUK++ExVIGFhcR3lSjR1xOdSxPfvxudY6/+EJlZtyOXTlz UuWdnk3W4zs8LWtigNWDVr0FGWHbOcP+njDIanzvqcRSnJFoqMVcVJwIACMHFY54AgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrAIsWRmVeSWpSXmKPExsUi2FA8W3fiolfhBqcXcVocfhZjsW7PN3aL 1s9vmCyWHdvBYtHR8Y/JgdVjzbw1jB67tu1k8li85yWTx6QLj5k93u+7yhbAGsVlk5Kak1mW WqRvl8CVcX/bKpaCC9wVe7rOMzYwzuTsYuTkkBAwkVjVcYIRwhaTuHBvPVsXIxeHkMAhRolX syezgyR4BQQlfky+x9LFyMHBLCAvcfC8LEiYWUBL4vujVhaI+h4miZ9XO8EGCQuIS7w7s4kZ wraWWDzzIyuIzSagLLFi/gewmZwC8RJzzn5hA7FZBFQlJt/4yAQyiFlgPaPExf0NUIttJDYc v8MOseENk8TB3iVgk0QEFCTedBxhArlIQkBWYvYvrwmMgrOQ3DoL4dZZSG5dwMi8ilGgKDUn sdJUL7GgICdVLzk/dxMjOLwLI3Yw/l9mdYhRgINRiYeXoehVuBBrYllxZS4wMDiYlUR4vecB hXhTEiurUovy44tKc1KLDzEmAz0wkVlKNDkfGHt5JfGGJiYGJsbGZsbG5ibmpAkrifOu430Q LiSQnliSmp2aWpBaBLOFiYNTqoHxbIHh2psfhKZeSnv9d9vOzTx5Kd7Hwno5vhj35J2yfudz sir3+MEPkW/WHYh1t2TUyvlzOFPr5qPl3h1fWRR8L8yrz14i9et7deTHBQLbbhvnLJqZyPhu jrTGV6Ofe9/OUt6V/tAjyfW5Bt/G+TUyuSdC/d09Mg50Vi07G6fA1PW1erb9F4dpSizFGYmG WsxFxYkAlYWUArMCAAA= 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:47:13 -0000 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII > On Sep 27, 2016, at 9:03 AM, Cohen, Eugene wrote: > >> Printing UINTN with %x *or* with %d are equally bugs. >> >> 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 [ducking and running]. :) > >>> 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. >> >> 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 code doesn't adhere to this recommendation. > I think this is a historical artifact. The older version of %x in the EDK (and early edk2) implied UINTN. We hit an issue with C integer math resulting in an int and that seemed to bork some toolchains. That is when things changed from UINTN to int. I guess the cleanup was practical vs. pedantic. Thanks, Andrew Fish > Thanks, > > Eugene > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel