[FFmpeg-cvslog] r14469 - trunk/libavcodec/ra288.c

Måns Rullgård mans
Tue Jul 29 21:49:38 CEST 2008


Uoti Urpala <uoti.urpala at pp1.inet.fi> writes:

> On Tue, 2008-07-29 at 19:41 +0100, M?ns Rullg?rd wrote:
>> IMO, it is better to declare things as unsigned, when a negative value
>> is meaningless.  It makes range checking simpler, if nothing else.
>
> I don't quite agree about using that as a general rule. Declaring
> something unsigned has more than one effect. First it means that it can
> never hold a negative value; that part is usually beneficial. However if
> you make an int-sized or larger variable unsigned it also means that the
> results of normal arithmetic operations involving the variable will
> become unsigned, and that can cause nasty traps. Even if a negative
> value for the variable itself would be meaningless that doesn't mean all
> calculations which use the variable and give a negative result would be
> meaningless.

That is a good point, and I have seen such bugs in real life
(ironically, created in an attempt to "fix" a warning).

-- 
M?ns Rullg?rd
mans at mansr.com




More information about the ffmpeg-cvslog mailing list