Re: patch: signed char issues

From: Horst von Brand (vonbrand@sleipnir.valparaiso.cl)
Date: Mon Apr 24 2000 - 05:27:10 EST


Russell King <rmk@arm.linux.org.uk> said:
> Horst von Brand writes:
> > Philip Blundell <Philip.Blundell@pobox.com> said:
> > > Here's a handful of patches for areas of the kernel that assume
> > > `char' is a signed type. It was generated against 2.3.99-pre3 but it
> > > seems to apply cleanly against -pre5 as well.

> > Are you sure this is really needed? On a machine with native unsigned char
> > this might be a sizeable performance impact for each use.

> I think you've misunderstood the patch. The problem is that:

> char wibble = -1;
>
> ...
>
> if (wibble == -1)
> printk("wibble is -1\n");
> else
> printk("wibble is not -1\n");

> will always print "wibble is not -1" on a native unsigned char machine.

Another solution would be to write:

       if (wibble == (char) -1)
               ...

This won't force signedness upon each access to wibble, and should work
everywhere.

-- 
Horst von Brand                             vonbrand@sleipnir.valparaiso.cl
Casilla 9G, Viņa del Mar, Chile                               +56 32 672616

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Apr 30 2000 - 21:00:08 EST