[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Nano-devel] [PATCH] browser: fix handling of large files
From: |
Benno Schulenberg |
Subject: |
Re: [Nano-devel] [PATCH] browser: fix handling of large files |
Date: |
Wed, 15 Jul 2015 20:45:33 +0200 |
On Wed, Jul 15, 2015, at 12:31, Mike Frysinger wrote:
> The current code relies on the undefined behavior of 1<<40. This fails
> because the compiler is free to optimize away checks like (1<<40 != 0).
> It also leads to build time warnings because "1" is an integer which is
> usually 32bits.
Yeah, I didn't like those warnings either, but it didn't occur to me how
to fix that.
> The code also assumes that sizeof(long) >= sizeof(off_t)
> even though we specifically build in LFS mode, so off_t should be 64bits
> while long will still be 32bits on most 32bit systems.
>
> Rather than unwind that though, replace the code with a proper off_t
Okay.
> and by re-using earlier variables so our shift checks always fit into
> 32bits.
> + if (modifier != 'G' || result < (1 << 10))
> + sprintf(foo, "%4ju %cB", (intmax_t)result, modifier);
The "modifier != 'G'" isn't needed, I think; "if (result < (1 << 10))"
should be enough, no?
Benno
--
http://www.fastmail.com - Choose from over 50 domains or use your own