[sane-devel] Fix for backend/epson.c
Karl Heinz Kremer
khk at khk.net
Sun Dec 8 11:23:25 GMT 2002
On Sun, Dec 08, 2002 at 12:13:08PM +0100, Henning Meier-Geinitz wrote:
> Hi,
>
> On Sun, Dec 08, 2002 at 11:49:22AM +0100, Aurelien Jarno wrote:
> > In backend/epson.c, lines 823 and 905, there is the following code:
> >
> > const u_char * s = buf;
> >
> > for( k = 0; k < buf_size; k++) {
> > DBG( 125, "buf[%u] %02x %c\n", k, s[k], isprint( s[k]) ? s[k] : '.');
> >
> > The second argument passed to DBG, s[k], is a char, but the compiler is
> > tell to read an int. It seems to work in most case, but it mail fail on
> > some architectures.
>
> Really? %x (or %u, %d etc) with a char argument is used in a lot more
> places in SANE.
>
> > + DBG( 125, "buf[%u] %02hhx %c\n", k, s[ k],
> > isprint( s[ k]) ? s[ k] : '.');
>
> >From the printf manpage:
>
> "glibc 2.1 adds length modifiers hh,j,t,z and conversion characters
> a,A."
>
> So is this portable?
I doubt this. I've never seen this modifiers anywhere else.
>
> If it's really necessary to fix anything here, wouldn't be the fix to
> cast the u_char to unsigned int?
If we really have to fix anything (which I doubt, a char is a numeric
argument in my book), casting the argument is the only fix I would
apply to my code.
Which compilers complain about this?
Karl Heinz
--
Karl Heinz Kremer khk at khk.net
PGP Key at http://www.khk.net/download/khk.asc
EPSON Sane Backend: http://www.khk.net
-------------- 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/20021208/7adb2291/attachment.sig>
More information about the sane-devel
mailing list