[sane-devel] Plustek backend: incorrect rounding

Aurelien Jarno lists at aurel32.net
Fri Dec 6 20:36:28 GMT 2002


Hello !

I am forwarding the following bug reported via the Debian BTS:

| In backend/plustek-usbimg.c, line 1363:
|
| if(!(a_bRegs[0x4e] = (u_char)ceil(dw / (4 * hw->wDRAMSize))))
|
| dw and hw->wDRAMSize are both integral types, meaning the division is
| done in integer arithmetic, the result is always rounded down instead of
| up, and the ceil() is left meaningless.

The following patch should fix that.

Aurelien


Index: sane-backends/backend/plustek-usbimg.c
===================================================================
RCS file:
/cvsroot/external/sane/sane-backends/backend/plustek-usbimg.c,v
retrieving revision 1.9
diff -u -1 -b -p -r1.9 plustek-usbimg.c
--- plustek-usbimg.c    2002/10/15 18:02:39     1.9
+++ plustek-usbimg.c    2002/12/06 19:57:07
@@ -1362,3 +1362,3 @@ static SANE_Int usb_ReadData( struct Plu
                {
-                       if(!(a_bRegs[0x4e] = (u_char)ceil(dw / (4 * hw->wDRAMSize))))			
+                       if(!(a_bRegs[0x4e] = (u_char)ceil(dw / (4.0 * hw->wDRAMSize))))
                                a_bRegs[0x4e] = 1;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/sane-devel/attachments/20021206/161f32dc/attachment.sig>


More information about the sane-devel mailing list