Re: [PATCH v2 11/18] maintenance: auto-size incremental-repack batch
- From
Chris Torek <chris.torek@gmail.com>
- Date
- Jul 30, 2020, 19:24 UTC
- Message-ID
- <CAPx1GvfcDeCBLMFbTtCpEK13uCWQQ+u=R1x1qE2kBD3eXVwh7A@mail.gmail.com>
- In-Reply-To
- <c0b9876a-9041-3400-25ac-e52568a02074@gmail.com>
On Thu, Jul 30, 2020 at 12:04 PM Derrick Stolee <stolee@gmail.com> wrote:
Show 7 quoted lines
> > This is actually ((1 << 31) - 1) because "unsigned long" is 32-bits > > on Windows. But it's better to not use magic numbers and instead use > > operations like this. > > Nevermind. This breaks the build on 32-bit machines (even adding a few > "L" characters). I'll replace my magic decimal number with a magic > hexadecimal number.
You would need something along these lines:
#define WHATEVER ((long)((1UL << 31) - 1))
i.e., make the constant 1 be "unsigned long" so that the shift is well defined, then subtract 1, then convert back to signed long.
I say "something along" because there are several more ways to write it. I'm not really a big fan of most of them, and 0x7FFFFFFF (or in lowercase) is my own preference here too.
Chris