[sane-devel] Fix for backend/epson.c

Karl Heinz Kremer khk@khk.net
Sun, 8 Dec 2002 06:23:25 -0500


--EeQfGwPcQSOJBaQU
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sun, Dec 08, 2002 at 12:13:08PM +0100, Henning Meier-Geinitz wrote:
> Hi,
>=20
> 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:
> >=20
> >      const u_char * s =3D buf;
> >=20
> >      for( k =3D 0; k < buf_size; k++) {
> >        DBG( 125, "buf[%u] %02x %c\n", k, s[k], isprint( s[k]) ? s[k] : =
'.');
> >=20
> > 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.
>=20
> Really? %x (or %u, %d etc) with a char argument is used in a lot more
> places in SANE.
>=20
> > +                       DBG( 125, "buf[%u] %02hhx %c\n", k, s[ k],
> >                                         isprint( s[ k]) ? s[ k] : '.');
>=20
> >From the printf manpage:
>=20
> "glibc 2.1 adds length modifiers hh,j,t,z and conversion characters
> a,A."
>=20
> So is this portable?

I doubt this. I've never seen this modifiers anywhere else.

>=20
> 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

--=20
Karl Heinz Kremer                                  khk@khk.net
PGP Key at                 http://www.khk.net/download/khk.asc
EPSON Sane Backend:                         http://www.khk.net

--EeQfGwPcQSOJBaQU
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE98yutxejv3RfKrhsRAnPyAJ99L1+kzXcS7cl2mV0VWADXnxjomQCfd+qc
Cbs5uJqBXzXKdzorW4SdcCc=
=w370
-----END PGP SIGNATURE-----

--EeQfGwPcQSOJBaQU--