On 05/21/10 00:20, Paolo Bonzini wrote:

> -      prepare_wc_buf (p, end);
> +      prepare_wc_buf ((const char *)p, end);

A better fix, in the long run anyway, is to remove the part of the code that
casts char * to unsigned char *, and to use char * uniformly.

The trick of casting char * to unsigned char * was originally put in there,
I expect, because circa-1990 compilers generated more efficient
code for *U, where U is of type unsigned char *, than they did for
((unsigned char) *S), where S is of type char *.  This is no longer
the case, so the trick isn't needed any more.

We can get rid of the casts by using a little function like this:

static inline unsigned char uc (char c) { return c; }

and then saying "uc (*S)" rather than "(unsigned char) *S".  This
is a bit safer than the cast, since it catches mistakes such as
when *S is itself a pointer.

Reply via email to