Re: [PATCH 4/6] Squelch warning about an integer overflow
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 26, 2015, 20:23 UTC
- Message-ID
- <xmqqpp01fkg5.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <b0e4b6736cc2ec88e5f7cf587629d6a4d7e502d8.1445865176.git.johannes.schindelin@gmx.de>
Johannes Schindelin <johannes.schindelin@gmx.de> writes:
> We cannot rely on long integers to have more than 32 bits... > > Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> > ---
Interesting. 8192 * 1024 * 1024 does not fit within 32-bit long, of course. Perhaps we can lose L after 1024 if we are explicitly saying that the result ought to be size_t (which may be larger than long)?
Show 16 quoted lines
> git-compat-util.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/git-compat-util.h b/git-compat-util.h > index 805d0e2..610e8a5 100644 > --- a/git-compat-util.h > +++ b/git-compat-util.h > @@ -568,7 +568,7 @@ extern int git_lstat(const char *, struct stat *); > #endif > > #define DEFAULT_PACKED_GIT_LIMIT \ > - ((1024L * 1024L) * (sizeof(void*) >= 8 ? 8192 : 256)) > + ((1024L * 1024L) * (size_t)(sizeof(void*) >= 8 ? 8192 : 256)) > > #ifdef NO_PREAD > #define pread git_pread