This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

IWR6843: Potential unhandled overflow in mmwavelib_log2Abs32

Part Number: IWR6843

For your information: Potential unhandled overflow in mmwavelib_log2Abs32

The following code is used this function

max = imag;
min = real;

if (real > imag)
{
max = real;
min = imag;
}

/* Approximate absolute function.
* abs (x[i] + ix[i+1]) \approx (max + min*3/8) */
absvalue = max + ((min * 3U) >> 3U);

Where imag and real are uint32_t values with 0 op to 0x80000000. There is the risk that at the "min * 3U" will perform an undetected overflow. (min >> 3U) * 3U, will almost give the same result but does not risk overflowing.

Secondly this is using very rude way of taking an absolute value, if you are taking an logarithm anyway there are more accurate ways of computing the absolute value and logarithm together with similar or better performance. Take a quick look at the function below in the same file ( mmwavelib_log2Abs16 ) and the mathematics rule: log(x^y) = y * log (x).