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

Aurelien Jarno lists@aurel32.net
Sun, 8 Dec 2002 12:50:05 +0100


--RnlQjJ0d97Da+TV1
Content-Type: text/plain; charset=iso-8859-15
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sun, Dec 08, 2002 at 06:23:25AM -0500, Karl Heinz Kremer wrote:
> 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?
>=20
> I doubt this. I've never seen this modifiers anywhere else.
>=20
> >=20
> > If it's really necessary to fix anything here, wouldn't be the fix to
> > cast the u_char to unsigned int?
Yes it seems it is not problem. The solution using cast seems to be
better.
=20
> 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.
>=20
> Which compilers complain about this?

Currently the submitter of the bug report has only tell me it *may*
cause problem on some compilers, but he hasn't give me a compiler with
which the problem appears.

Aurelien

--RnlQjJ0d97Da+TV1
Content-Type: application/pgp-signature
Content-Disposition: inline

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

iD8DBQE98zHtw3ao2vG823MRAhOcAJ9F6qZoxJXHRKEScEIS1Lxv3JSWcwCffJ3M
LChNqDlb6qK65QtoRbtyqZ8=
=TGrg
-----END PGP SIGNATURE-----

--RnlQjJ0d97Da+TV1--