[sane-devel] Developers take note: Backend initialization

Olaf Meeuwissen olaf.meeuwissen at avasys.jp
Wed Dec 8 01:00:12 UTC 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2010-12-08 08:37, m. allan noah wrote:
> On Tue, Dec 7, 2010 at 6:04 PM, Olaf Meeuwissen wrote:
>> On 2010-12-07 22:32, m. allan noah wrote:
>>> On Tue, Dec 7, 2010 at 12:43 AM, Olaf Meeuwissen wrote:
>>> [...]
>>>> Backends can safely call sanei_usb_init() in both sane_init() and
>>>> sane_get_devices().  They should just move the device discovery logic to
>>>> sane_get_devices() and call that from sane_init() if they really still
>>>> want to do discovery at sane_init().
>>>
>>> Actually, since sane_init() calls are usually followed by
>>> sane_get_devices(), [...]
>>
>> The problem is with "usually".  Backend maintainers have no guarantee
>> from the spec that frontends will do so.
> 
> Certainly, but the 'usually' means than most of the time, the backend
> would search for devices in sane_init, and do it again a millisecond
> later in sane_get_devices.

I'm not a big fan of doing more than necessary, so suggest that all
sane_init() implementations refrain from doing device discovery.  That's
not the job of sane_init().
# I did say "if they really still want to" above ;-)

>> In the epkowa backend I also call sane_get_devices() in sane_open() if
>> it hasn't been called yet but that's just because I'm too lazy to:
>>  - decide what the first available device is in case of no device name
>>  - bother with validating the device name properly (it's easier to see
>> whether it's in the list)
> 
> If its lazy but it works, it's not lazy :)

Laziness is one of the Programmer Virtues in some places ;-)

> So, lets consider my original request amended with this later
> suggestion- watch out for the case of a front-end which does not call
> sane_get_devices.

How about slapping backend maintainers with the spec an tell them to get
their act together ;-)

Hope this helps,
- -- 
Olaf Meeuwissen, LPIC-2           FLOSS Engineer -- AVASYS CORPORATION
FSF Associate Member #1962               Help support software freedom
                 http://www.fsf.org/jf?referrer=1962
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkz+2JwACgkQt5qrxaZLMnL42QCdEqwO2S8lTN2PZQER3Uo0T0Hg
zWoAnRtkdQsoom3W7a4iGd261umIIYf6
=CYgC
-----END PGP SIGNATURE-----



More information about the sane-devel mailing list