[PATCH 2/2] os: Work around integer overflow in TimerSet.
walter harms
wharms at bfs.de
Mon Mar 7 03:05:45 PST 2011
Am 06.03.2011 21:34, schrieb Fernando Carrijo:
> Cyril Brulebois <kibi at debian.org> wrote:
>
>> If TimerSet gets called with a big timeout, this call can overflow:
>> millis += now;
>>
>> Detect overflow and set millis to the maximal integer when that happens,
>> to avoid falling in the “already expired” case.
>
> Hi Cyril,
>
> I found this, buried in Section 6.2.5 (9) of the C Standard:
>
> A computation involving unsigned operands can never overflow,
> because a result that cannot be represented by the resulting
> unsigned integer type is reduced modulo the number that is one
> greater than the largest value that can be represented by the
> resulting type.
>
What they mean is: we will not access a memoryadress beyond because any
overflow will return to zero.
for uchar this means: 0xff +0x1 -> 0x00 what is still a char.
re,
wh
> So, I presume, something isn't quite right in this series.
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
More information about the xorg-devel
mailing list