ape: Avoid undefined behaviour
authorLuca Barbato <lu_zero@gentoo.org>
Tue, 12 Apr 2016 20:14:26 +0000 (22:14 +0200)
committerLuca Barbato <lu_zero@gentoo.org>
Tue, 19 Apr 2016 18:22:31 +0000 (20:22 +0200)
Avoid the clang warning

"warning: shifting a negative signed value is undefined"

libavcodec/apedec.c

index d33139b..85d26ae 100644 (file)
@@ -1305,7 +1305,7 @@ static void do_apply_filter(APEContext *ctx, int version, APEFilter *f,
             /* Update the adaption coefficients */
             absres = FFABS(res);
             if (absres)
-                *f->adaptcoeffs = ((res & (-1<<31)) ^ (-1<<30)) >>
+                *f->adaptcoeffs = ((res & ((~0UL) << 31)) ^ ((~0UL) << 30)) >>
                                   (25 + (absres <= f->avg*3) + (absres <= f->avg*4/3));
             else
                 *f->adaptcoeffs = 0;