[sane-devel] coolscan2 in 1.0.8

Major A andras@users.sourceforge.net
Sun, 14 Apr 2002 16:18:25 +0100


Frank,

> s can also leak when cs2_open() is called recursively.

OK, you are right, I fixed these now.

> You should also remove the default case in the switch (interface)
> in cs2_open() and enumerates all the cases instead. gcc will warn if
> there is some missing cases.

I've done that, but what is the reason for this? Why shouldn't I use
default instead of CS2_INTERFACE_UNKNOWN, which in all but one case
would lead to an error anyway?

> same function, if sp is NULL, s is always leaked.

No, because cs2_close() is called.

> And memset'ing this variable to 0 when allocated wouldn't hurt.

Done, although all structure members should be initialized in
sane_open() anyway.

> This function has a reason to return a value; the caller should check for
> it and act appropriatly. The remark about cs2_scanner_ready() is also
> valid for cs2_focus(), cs2_pack_byte(), cs2_eject() and more. My
> impression here is that the backend is rather fragile once an error
> happen.

Yes, I will go through this later today.

> sane_control_option() is missing some tests, but I think tstbackend will
> tell you that.

I'll check this when I get home (where the scanner is).

> The free() is cs2_close() makes all the buffers allocated for the device
> leak.

Fixed already.

> I'm being nit-picking, but in cs2_attach(), can't
>   device = (char *) cs2_xmalloc (strlen (dev) + 1);
>   strcpy (device, dev);
>   status = cs2_open (device, try_interface, NULL);
>   free (device);
> be replaced by
>   status = cs2_open (dev, try_interface, NULL);
> ?
> (which leads to the fact that the first argument to cs2_open should be a
> const).

It can. Can't think of the reason why I it this way.

Thanks a lot,

  Andras

===========================================================================
Major Andras
    e-mail: andras@users.sourceforge.net
    www:    http://andras.webhop.org/
===========================================================================