math: don't use implicit types in fixed point math

Cppcheck is complaining that we are running a 32bit int off the end.
This shouldn't happen here in any arch. Looking at the math and
comments, it looks like idx should be a 64 type or cast to a larger
container before the bit shift. Therefore I am enforcing a strict type
on it.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
This commit is contained in:
Curtis Malainey 2021-02-19 14:48:53 -08:00 committed by Liam Girdwood
parent 6d9ce240e2
commit 5116f070c2
1 changed files with 2 additions and 2 deletions

View File

@ -552,17 +552,17 @@ static inline int32_t sine_lookup(int idx)
/* Compute fixed point sine with table lookup and interpolation */
int32_t sin_fixed(int32_t w)
{
int idx;
int32_t frac;
int32_t s0;
int32_t s1;
int32_t delta;
int64_t idx;
int64_t sine;
int64_t idx_tmp;
/* Q4.28 x Q12.20 -> Q16.48 */
idx_tmp = (int64_t)w * SINE_C_Q20;
idx = (int)(idx_tmp >> 48); /* Shift to Q0 */
idx = (idx_tmp >> 48); /* Shift to Q0 */
idx_tmp = idx_tmp >> 17; /* Shift to Q16.31 */
idx_tmp = idx_tmp - (idx << 31); /* Get fraction */
frac = (int32_t)idx_tmp; /* Q1.31 */