From 2efdd5a3340379c49f4914ec22f1397bb2f4d61a Mon Sep 17 00:00:00 2001 From: David Ward Date: Tue, 8 Mar 2022 19:00:00 -0500 Subject: [PATCH] plustek: Adjust gain calculation to avoid calling labs() labs() has a signed parameter. However the argument to it here was the difference between two unsigned values, which itself remains unsigned. GCC warned that using this in labs() might not have the intended result. By definition though, dwInc >= m_dwIdealGain >= dwDec, so labs() is not even needed in this expression. --- backend/plustek-usbshading.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/plustek-usbshading.c b/backend/plustek-usbshading.c index c585c8bbb..f7eb61949 100644 --- a/backend/plustek-usbshading.c +++ b/backend/plustek-usbshading.c @@ -685,7 +685,7 @@ static u_char usb_GetNewGain( Plustek_Device *dev, u_short wMax, int channel ) dwInc = (u_long)((0.93 + ceil (dRatio) * 0.067) * wMax / dAmp); dwDec = (u_long)((0.93 + floor (dRatio) * 0.067) * wMax / dAmp); if((dwInc >= 0xff00) || - (labs (dwInc - m_dwIdealGain) > labs(dwDec - m_dwIdealGain))) { + (dwInc - m_dwIdealGain > m_dwIdealGain - dwDec)) { bGain = (u_char)floor(dRatio); } else { bGain = (u_char)ceil(dRatio);