kopia lustrzana https://gitlab.com/sane-project/backends
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.escl-add-user-and-password
rodzic
5576d03afd
commit
2efdd5a334
|
@ -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);
|
||||
|
|
Ładowanie…
Reference in New Issue