Frank Lichtenheld <[EMAIL PROTECTED]> writes:

> |       [CC]   src/main/event.o
> | cc1: warnings being treated as errors
> | /build/buildd/elinks-0.12~20080127/src/main/event.c: In function 
> 'unregister_event_hook':
> | /build/buildd/elinks-0.12~20080127/src/util/math.h:36: error: assuming 
> signed overflow does not occur when assuming that (X + c) < X is always false

The code in unregister_event_hook() is:

|               for (i = 0; i < event->count; i++) {
|                       if (event->handlers[i].callback != callback)
|                               continue;
|
|                       move_event_handler(event, i, i + 1);

which calls:

| static inline void
| move_event_handler(struct event *event, int to, int from)
| {
|       int d = int_max(to, from);

which is defined in src/util/math.h as:

| static inline int
| int_max(register int x, register int y)
| {
|       if (x > y) return x;
|       return y;
| }

So GCC warns about the i > i + 1 comparison.  I think the i + 1
is very unlikely to overflow in practice, although it is possible
because event->count is unsigned int and i is signed int.  Also,
the overflow would need a 64-bit machine because otherwise
register_event_hook() would run out of memory first.

However, there are other places in ELinks where signed overflows
are possible and are expected to wrap around.  The one such place
I know about is parse_bencoding_integer().  You should therefore
compile ELinks with -fno-strict-overflow or -fwrapv.  I will add
one of those to the configure script when I have time.

Attachment: pgpofBDxOye4F.pgp
Description: PGP signature

Reply via email to