From 4070166f4a04cf66595dcfdb32898abc8cfc2bdf Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Fri, 3 Feb 2023 11:54:24 +0100 Subject: [PATCH] Avoid signed/unsigned comparison when possible As reported by -Wall -- Cherry-picked from https://gitlab.com/serge-sans-paille/soundtouch/-/tree/fix/sign-issue --- source/SoundTouch/FIRFilter.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/SoundTouch/FIRFilter.cpp b/source/SoundTouch/FIRFilter.cpp index 260003e..7a6d9ec 100644 --- a/source/SoundTouch/FIRFilter.cpp +++ b/source/SoundTouch/FIRFilter.cpp @@ -81,9 +81,10 @@ uint FIRFilter::evaluateFilterStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, ui double dScaler = 1.0 / (double)resultDivider; #endif // hint compiler autovectorization that loop length is divisible by 8 - int ilength = length & -8; + uint ilength = length & -8; assert((length != 0) && (length == ilength) && (src != NULL) && (dest != NULL) && (filterCoeffs != NULL)); + assert(numSamples > ilength); end = 2 * (numSamples - ilength); @@ -96,7 +97,7 @@ uint FIRFilter::evaluateFilterStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, ui suml = sumr = 0; ptr = src + j; - for (int i = 0; i < ilength; i ++) + for (uint i = 0; i < ilength; i ++) { suml += ptr[2 * i] * filterCoeffsStereo[2 * i]; sumr += ptr[2 * i + 1] * filterCoeffsStereo[2 * i + 1];