public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Kinney, Michael D" <michael.d.kinney@intel.com>
To: "Cohen, Eugene" <eugene@hp.com>,
	"afish@apple.com" <afish@apple.com>,
	"Kinney, Michael D" <michael.d.kinney@intel.com>
Cc: Alexei Fedorov <Alexei.Fedorov@arm.com>,
	"edk2-devel@lists.01.org" <edk2-devel@ml01.01.org>,
	Laszlo Ersek <lersek@redhat.com>
Subject: Re: What is the right way to print a UINTN?
Date: Tue, 27 Sep 2016 20:10:53 +0000	[thread overview]
Message-ID: <E92EE9817A31E24EB0585FDF735412F56481CC0A@ORSMSX113.amr.corp.intel.com> (raw)
In-Reply-To: <AT5PR84MB029160630A38A120C9D03AA9B4CC0@AT5PR84MB0291.NAMPRD84.PROD.OUTLOOK.COM>

Eugene,

I agree.  There are use cases for using UINTN so values can scale to CPU arch.

Casting those specific use cases from UINTN to UINT64 when used in a print call 
is likely the safest method.

There are many use case of UINTN where the value is limited to 32-bits, and
a typecast is not required.

The format specifier idea is interesting.  I need to lookup the ANSI C versions
of those.  Looks like they were introduced in C99.

Mike


> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Cohen, Eugene
> Sent: Tuesday, September 27, 2016 12:29 PM
> To: Kinney, Michael D <michael.d.kinney@intel.com>; afish@apple.com
> Cc: Alexei Fedorov <Alexei.Fedorov@arm.com>; edk2-devel@lists.01.org <edk2-
> devel@ml01.01.org>; Laszlo Ersek <lersek@redhat.com>
> Subject: Re: [edk2] What is the right way to print a UINTN?
> 
> MIke,
> 
> > Portable sources that use type UINTN must never use values larger
> > than
> > 32-bits.  Same for type INTN.  Only use values in signed 32-bit range.
> 
> If the value is something like an enumeration or bitmask then I agree, but not if it's
> something numeric that is supposed to scale to larger numbers on 64-bit platforms like
> the Length field of CopyMem.
> 
> I like the proposals to use a custom format specifier (although the concatenated string
> with macro will take some getting used to).
> 
> Thanks,
> 
> Eugene
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


      reply	other threads:[~2016-09-27 20:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-26 13:46 What is the right way to print a UINTN? Cohen, Eugene
2016-09-26 14:39 ` Alexei Fedorov
2016-09-26 15:31 ` Laszlo Ersek
2016-09-27 12:29   ` Cohen, Eugene
2016-09-27 14:30     ` Laszlo Ersek
2016-09-27 16:03       ` Cohen, Eugene
2016-09-27 16:31         ` Laszlo Ersek
2016-09-27 16:47         ` Andrew Fish
2016-09-27 17:14           ` Brian J. Johnson
2016-09-27 18:31             ` Laszlo Ersek
2016-09-27 20:27             ` Kinney, Michael D
2016-09-27 17:27           ` Kinney, Michael D
2016-09-27 17:46             ` Andrew Fish
2016-09-27 18:20               ` Kinney, Michael D
2016-09-27 19:28             ` Cohen, Eugene
2016-09-27 20:10               ` Kinney, Michael D [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E92EE9817A31E24EB0585FDF735412F56481CC0A@ORSMSX113.amr.corp.intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox