Don't rely on signed-integer overflow to detect out-of-range values.

Signed-integer overflow is undefined behaviour in C.

Change-Id: Ib2d7f405adacc668264a5d77aba00ca85ecbb0f7
This commit is contained in:
Sebastien Alaiwan 2017-02-03 10:25:51 +01:00 коммит произвёл sebastien alaiwan
Родитель 1a02439fa0
Коммит a5d892bdb8
1 изменённых файлов: 1 добавлений и 1 удалений

Просмотреть файл

@ -95,7 +95,7 @@ static INLINE int32_t half_btf(int32_t w0, int32_t in0, int32_t w1, int32_t in1,
int32_t result_32 = w0 * in0 + w1 * in1;
#if CONFIG_COEFFICIENT_RANGE_CHECKING
int64_t result_64 = (int64_t)w0 * (int64_t)in0 + (int64_t)w1 * (int64_t)in1;
if (result_32 != result_64) {
if (result_64 < INT32_MIN || result_64 > INT32_MAX) {
printf("%s %d overflow result_32: %d result_64: %" PRId64
" w0: %d in0: %d w1: %d in1: "
"%d\n",