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

Henning Meier-Geinitz henning@meier-geinitz.de
Sun, 8 Dec 2002 12:13:08 +0100


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:
Status: O

"glibc 2.1 adds length modifiers hh,j,t,z and conversion characters
a,A."

So is this portable?

If it's really necessary to fix anything here, wouldn't be the fix to
cast the u_char to unsigned int?

Bye,
  Henning