public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Timur Tabi <timur@freescale.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] fix print_size printing fractional gigabyte numbers on 32-bit platforms
Date: Tue, 30 Mar 2010 17:08:47 -0500	[thread overview]
Message-ID: <4BB2766F.9070808@freescale.com> (raw)
In-Reply-To: <4BB275B7.90509@freescale.com>

Scott Wood wrote:
> In changing "d" from phys_size_t to unsigned long, I think you're 
> introducing overflow in "n * d" (consider 5.5G rather than 1.5G).
> 
> Wouldn't a more straightforward fix, that doesn't affect the function 
> signature, be to just change "10 *" to "10ULL *"?

I don't see how that suggestion would make the code any different.  Here's the expression:

	(10 * (size - (n * d)) + (d / 2) ) / d;

I made 'size' into a u64, and I assume that the compiler will evaluate every other subexpression as a u64.  That may be wrong.

However, changing 10 to 10ULL makes the same assumption.

I'll test 5.5GB and see what it does.

-- 
Timur Tabi
Linux kernel developer at Freescale

  reply	other threads:[~2010-03-30 22:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-30 21:53 [U-Boot] [PATCH] fix print_size printing fractional gigabyte numbers on 32-bit platforms Timur Tabi
2010-03-30 22:05 ` Scott Wood
2010-03-30 22:08   ` Timur Tabi [this message]
2010-03-30 22:19     ` Scott Wood
2010-03-30 22:32       ` Timur Tabi
2010-03-30 22:39         ` Scott Wood

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-all 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=4BB2766F.9070808@freescale.com \
    --to=timur@freescale.com \
    --cc=u-boot@lists.denx.de \
    /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