[pacman-dev] [PATCH] Fix gcc strict-overflow error
Andrew Gregory
andrew.gregory.8 at gmail.com
Tue Sep 20 13:17:23 UTC 2016
On 09/20/16 at 10:50pm, Allan McRae wrote:
> On 18/09/16 01:13, Rikard Falkeborn wrote:
> > Recent gcc (tested with 6.2.1) produces the following error when
> > compiling with both --enable-warningflags and --enable-debug.
> > In particular, it seems it is the combination of GCC_STACK_PROTECT_LIB
> > and -Wstrict-overflow=5 produces the error.
> >
> > be_local.c:609:4: error: assuming signed overflow does not occur
> > when simplifying conditional
> > [-Werror=strict-overflow]
> > if(count > 0) {
> >
> > Fix this by changing the type of count from int to size_t, which is
> > fine since count is never negative.
>
> Thanks.
>
> I was a bit wary given we are still returning casting to an int in the
> return, but this brings the local db handling of counts in line with the
> sync_db function so doe snot make anything worse...
>
> Allan
We don't actually use the returned count, so we could go ahead and
change the return for each function to a simple boolean.
apg
More information about the pacman-dev
mailing list