[FFmpeg-devel] [PATCH] Fix warning in av_rescale_rnd (in libavutil/mathematics.c)
Sat Jul 3 17:22:39 CEST 2010
On Sat, Jul 3, 2010 at 7:23 AM, M?ns Rullg?rd <mans at mansr.com> wrote:
> Reimar D?ffinger <Reimar.Doeffinger at gmx.de> writes:
>> On Sat, Jul 03, 2010 at 12:17:25PM +0200, Michael Niedermayer wrote:
>>> On Sat, Jul 03, 2010 at 12:42:08AM -0700, Eli Friedman wrote:
>>> > Patch attached. ?Fixes warning "comparison of unsigned expression >= 0
>>> > is always true".
>>> god damn, its a assert(), what is wrong with asserting that a variable
>>> is unsigned or if signed is positive. Why is gcc so retarded
>> Umm, gcc just can't know your intention. I have seen this kind of
>> thing quite a few times where it was an actual bug because someone
>> forgot to make a variable signed.
>> That said, casting the value to int before the comparison should
>> avoid the warning...
> Or cast it to unsigned and check only the upper limit.
Version like this attached.
-------------- next part --------------
--- libavutil/mathematics.c (revision 24018)
+++ libavutil/mathematics.c (working copy)
@@ -78,7 +78,7 @@
assert(c > 0);
- assert(rnd >=0 && rnd<=5 && rnd!=4);
+ assert((unsigned)rnd<=5 && rnd!=4);
if(a<0 && a != INT64_MIN) return -av_rescale_rnd(-a, b, c, rnd ^ ((rnd>>1)&1));
More information about the ffmpeg-devel