[FFmpeg-devel] [PATCH] Fix warning in av_rescale_rnd (in libavutil/mathematics.c)

Michael Niedermayer michaelni
Sat Jul 3 18:33:40 CEST 2010


On Sat, Jul 03, 2010 at 08:22:39AM -0700, Eli Friedman wrote:
> 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.
> 
> -Eli

> Index: libavutil/mathematics.c
> ===================================================================
> --- libavutil/mathematics.c	(revision 24018)
> +++ libavutil/mathematics.c	(working copy)
> @@ -78,7 +78,7 @@
>      int64_t r=0;
>      assert(c > 0);
>      assert(b >=0);
> -    assert(rnd >=0 && rnd<=5 && rnd!=4);
> +    assert((unsigned)rnd<=5 && rnd!=4);

ok

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100703/8dbd0cb7/attachment.pgp>



More information about the ffmpeg-devel mailing list