From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4108D81ED5 for ; Tue, 15 Nov 2016 10:11:18 -0800 (PST) Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7D4407EA82; Tue, 15 Nov 2016 18:11:22 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-97.phx2.redhat.com [10.3.116.97]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uAFIBKZ3019382; Tue, 15 Nov 2016 13:11:21 -0500 To: Andrew Fish , Jeff Fan , Feng Tian , Mike Kinney References: <20161115083213.7700-1-jeff.fan@intel.com> Cc: "edk2-devel@lists.01.org" From: Laszlo Ersek Message-ID: <4804ad49-f8d9-90d5-21f5-7b44d2229b95@redhat.com> Date: Tue, 15 Nov 2016 19:11:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 15 Nov 2016 18:11:22 +0000 (UTC) Subject: Re: [PATCH] UefiCpuPkg/SecCore: Use %x to print stack information 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, 15 Nov 2016 18:11:18 -0000 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit On 11/15/16 18:47, Andrew Fish wrote: > >> On Nov 15, 2016, at 8:59 AM, Laszlo Ersek > > wrote: >> >> On 11/15/16 09:32, Jeff Fan wrote: >>> SecCoreData->StackBase is VOID * type and SecCoreData->StackSize is >>> UINTN type. >>> We should use %x to dump their value instead of %lx. >>> >>> Cast pointer type to UINTN before print it. >>> >>> Cc: Feng Tian > >>> Cc: Michael D Kinney >> > >>> Contributed-under: TianoCore Contribution Agreement 1.0 >>> Signed-off-by: Jeff Fan > >>> --- >>> UefiCpuPkg/SecCore/SecMain.c | 4 ++-- >>> 1 file changed, 2 insertions(+), 2 deletions(-) >>> >>> diff --git a/UefiCpuPkg/SecCore/SecMain.c b/UefiCpuPkg/SecCore/SecMain.c >>> index 2ebbc22..4d08f48 100644 >>> --- a/UefiCpuPkg/SecCore/SecMain.c >>> +++ b/UefiCpuPkg/SecCore/SecMain.c >>> @@ -239,9 +239,9 @@ SecStartupPhase2( >>> >>> DEBUG (( >>> DEBUG_INFO, >>> - "%a() Stack Base: 0x%lx, Stack Size: 0x%lx\n", >>> + "%a() Stack Base: 0x%x, Stack Size: 0x%x\n", >>> __FUNCTION__, >>> - SecCoreData->StackBase, >>> + (UINTN) SecCoreData->StackBase, >>> SecCoreData->StackSize >>> )); >>> >>> >> >> Not disagreeing, just mentioning for completeness: we can also use %p >> for printing (VOID*) directly. >> > > %x is sizeof(int) not sizeof(UINTN)? Sigh, you are correct, of course. "%x" is not portable for printing UINTN. In fact we recently discussed just that: [edk2] What is the right way to print a UINTN? https://lists.01.org/pipermail/edk2-devel/2016-September/002091.html (There seem to be issues with my focus / attention recently... This is now the second near-trivial issue I've missed in a couple of days. :( I guess I should get more sleep.) > So it seems %p would be more > correct? Or we should just use UINT32 if that is what is intended. > > https://github.com/tianocore/edk2/blob/master/MdePkg/Include/Library/PrintLib.h#L80 > > - x > - The argument is an unsigned hexadecimal number. The characters used > are 0..9 and > A..F. If the flag 'L' is not specified, then the argument is assumed > to be size int. This does not follow ANSI C. > Right, %p is the most direct choice. Thank you Andrew! Laszlo