Portbility problems with sane 1.0.25

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Portbility problems with sane 1.0.25

Luiz Angelo Daros de Luca
Hello,

Thanks for the new release! It merged most of the patches I kept in order to compile for OpenWRT. However, I still faced some new and old problems:

a) backend/pieusb_buffer.c (most of the problems)

a.1) it uses mkostemp without checking its presence. uclibc might not provide it. If mkstemp is enough, it might be better as it is POSIX and not a glibc extension. I simply replaced it with mkstemp, which might not be correct.

a.2) le16toh is always redefined, which gives me a "redefined warning". The problem is that the replacement implementation uses __bswap_16, which is not present in musl. As le16toh might be already fine, check for it before reimplementing it:

a.3) if mmap is not found, it generates a compile error ("#error mmap(2) not available, aborting"). The problem is that mmap is checked with AC_FUNC_MMAP and it depends on a runtime check (ac_fn_c_try_run). As I'm crosscompiling, no runtime check will ever work because all generated binaries cannot run in my host system. If "AC_CHECK_FUNCS(mmap)" is not good enough as a replacement, configure would need to check for other hints (SO, arch) and heuristically define if mmap is avaiable. Anyway, if ever mmap check fails, the expected result would be to disable pieusb backend and never generate a compiler error.
I have no patch for this as I cheated the test defining ac_cv_func_mmap_fixed_mapped=yes

b) missing includes for sys/types.h (uchar and ulong)

This is an old problem still not fixed. The list of files that need to include sys/types.h added the new backend epsonds

- include/sane/sanei_udp.h
- backend/kvs20xx_cmd.h
- backend/kvs40xx.h
- backend/hp5400.c
- backend/hp5590.c
- backend/epsonds-io.c (new)

Even these files including sane/config.h, sane/config.h only includes sys/types.h when replacing some missing functions (inet_ntop, strndup).
Each problematic file might need something like:

#if defined(HAVE_SYS_TYPES_H)
# include <sys/types.h>
#endif

which is already used in some files (backend/umax_pp_low.c backend/umax_pp.c backend/genesys_low.h backend/mustek_pp.c backend/mustek_pp.h backend/pixma_bjnp.c)
or it could be added to sane/config.h (bruteforce solution).

I do have a patch but before upstreaming it, we need to define where to put the include.

Regards,

--

Luiz Angelo Daros de Luca


--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Portbility problems with sane 1.0.25

Olaf Meeuwissen-4
Hi Luiz,

Luiz Angelo Daros de Luca writes:

> Hello,
>
> Thanks for the new release! It merged most of the patches I kept in order
> to compile for OpenWRT. However, I still faced some new and old problems:
>
> a) backend/pieusb_buffer.c (most of the problems)

This file was only added a good month before the release, so, yes, there
are probably a few portability glitches.  Could you file bug reports with
Alioth for each of these issues so we won't forget?

> a.1) it uses mkostemp without checking its presence.
> a.2) le16toh is always redefined, which gives me a "redefined warning".
> a.3) if mmap is not found, it generates a compile error

With regard to

> b) missing includes for sys/types.h (uchar and ulong)
>
> This is an old problem still not fixed.

This will pop up everytime someone uses these types because, IMHO, the
./configure jobs only does half a job and leaves everyone in the dark as
to whether you may need to include <sys/types.h>.

> Each problematic file might need something like:
>
> #if defined(HAVE_SYS_TYPES_H)
> # include <sys/types.h>
> #endif

And then you may still have a problem is HAVE_SYS_TYPES_H is undefined.
Is using an ill-defined convenience typedef (or #define, who knows?) to
save a couple of keystrokes worth this kind of trouble?

> which is already used in some files

Some?  That's an understatement ;-)

> or it could be added to sane/config.h (bruteforce solution).

I don't like that brute force approach.  I'm inclined to use some brute
force `sed` instead ;-)

Hope this helps,
--
Olaf Meeuwissen, LPIC-2            FSF Associate Member since 2004-01-27
Support Free Software               Support the Free Software Foundation
https://my.fsf.org/donate                        https://my.fsf.org/join
 GnuPG key: F84A2DD9/B3C0 2F47 EA19 64F4 9F13  F43E B8A4 A88A F84A 2DD9


--
sane-devel mailing list: [hidden email]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
             to [hidden email]
Loading...