diff options
author | Jean-Marc Valin <jmvalin@amazon.com> | 2022-07-02 22:46:14 -0400 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@amazon.com> | 2022-07-05 17:27:31 -0400 |
commit | 3cc09dee34a22f89385447fb7bd230140316281f (patch) | |
tree | b1cceff4db35a0d87c2de544808b8b76c26df02d /celt/fixed_debug.h | |
parent | e535e894196387b12d9fcbc271a98b21572a630b (diff) | |
download | opus-3cc09dee34a22f89385447fb7bd230140316281f.tar.gz |
Avoid left shifts of negative values in debug macros
Reviewed by Mark Harris
Diffstat (limited to 'celt/fixed_debug.h')
-rw-r--r-- | celt/fixed_debug.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/celt/fixed_debug.h b/celt/fixed_debug.h index 92f0f47a..c2cf5a83 100644 --- a/celt/fixed_debug.h +++ b/celt/fixed_debug.h @@ -167,7 +167,7 @@ static OPUS_INLINE short SHR16_(int a, int shift, char *file, int line) #define SHL16(a, shift) SHL16_(a, shift, __FILE__, __LINE__) static OPUS_INLINE short SHL16_(int a, int shift, char *file, int line) { - int res; + opus_int32 res; if (!VERIFY_SHORT(a) || !VERIFY_SHORT(shift)) { fprintf (stderr, "SHL16: inputs are not short: %d %d in %s: line %d\n", a, shift, file, line); @@ -175,7 +175,7 @@ static OPUS_INLINE short SHL16_(int a, int shift, char *file, int line) celt_assert(0); #endif } - res = a<<shift; + res = (opus_int32)((opus_uint32)a<<shift); if (!VERIFY_SHORT(res)) { fprintf (stderr, "SHL16: output is not short: %d in %s: line %d\n", res, file, line); @@ -219,7 +219,7 @@ static OPUS_INLINE int SHL32_(opus_int64 a, int shift, char *file, int line) celt_assert(0); #endif } - res = a<<shift; + res = (opus_int64)((opus_uint64)a<<shift); if (!VERIFY_INT(res)) { fprintf (stderr, "SHL32: output is not int: %lld<<%d = %lld in %s: line %d\n", (long long)a, shift, (long long)res, file, line); |