[sane-devel] New magicolor backend for inclusion in git
Reinhold Kainhofer
reinhold at kainhofer.com
Thu Jan 20 18:35:37 UTC 2011
Am Donnerstag, 20. Januar 2011, um 16:24:06 schrieb Brian Shaver:
> I'm having some trouble compiling with these changes committed. Below is
> the error I'm getting. I'll admit I haven't actually looked into the
> source code to confirm the change comes from this set of commits, but it
> seemed like it would be related. I'm running Fedora 13, and I've been able
> to build from the latest source as recent as 2011.01.12.
Yes, these warning/errors come from my new magicolor backend.
FWIW, I have been developing on a 32-bit KUbuntu Linux machine.
> magicolor.c: In function 'dump_hex_buffer_dense':
> magicolor.c:400: warning: format '%04x' expects type 'unsigned int', but
> argument 3 has type 'size_t'
> magicolor.c: In function 'mc_send':
> magicolor.c:492: warning: format '%d' expects type 'int', but argument 3
> has type 'size_t'
Oops, that's a portability problem: How shall I print size_t objects with
printf in SANE? A google search showed some people advocating the use of
casting to unsigned long and printf'ing that:
printf("%lu\n", (unsigned long)x);
Shall I use that instead in SANE code?
Or is it possible to use the z modifier for size_t arguments (which is not
C90, AFAICS)? i.e.
printf("%zu\n", x);
> magicolor.c: In function 'cmd_start_scan':
> magicolor.c:680: warning: pointer of type 'void *' used in arithmetic
> magicolor.c:680: warning: dereferencing 'void *' pointer
> magicolor.c:680: error: invalid use of void expression
That line (and the other error in line 921) is simply calling the htole32a
macro that is defined in byteorder.h (I didn't touch that one).
Apparently, on your system, htole32a does not like a void* pointer as its
first argument. On my system, I tried using the same code as the epson2-ops.c
file:
unsigned char params1[4];
htole32a(¶ms1[0], value);
but that gave me the compiler warning
magicolor.c: In function 'cmd_start_scan':
magicolor.c:678: warning: dereferencing type-punned pointer will break strict-
aliasing rules
The code
unsigned char params1[4];
void *tmp = ¶ms1[0];
htole32a(tmp, value);
didn't give me any warnings and worked fine on my system.
> magicolor.c: In function 'mc_network_discovery':
> magicolor.c:1868: warning: unused parameter 'host'
That warning is there, because HAVE_LIBSNMP is not defined, so all of the
commands in mc_network_discovery are commented out by a #if HAVE_LIBSNMP.
Unfortunately, the autofoo reconf seems to have missed to add the HAVE_LIBSNMP
variable to configure.h.in (so SNMP was never enabled, even if you have the
net-snmp development files installed). I'll commit a fix for that shortly, so
that warning won't appear when you have the net-snmp library (and dev files)
installed. If you don't have it, then you'll still get that warning.
Cheers,
Reinhold
--
------------------------------------------------------------------
Reinhold Kainhofer, reinhold at kainhofer.com, http://reinhold.kainhofer.com/
* Financial & Actuarial Math., Vienna Univ. of Technology, Austria
* http://www.fam.tuwien.ac.at/, DVR: 0005886
* LilyPond, Music typesetting, http://www.lilypond.org
More information about the sane-devel
mailing list