Re: 2.1.120pre2: Bug in strnicmp() noted in 2.1.119pre1 is still there!

Michael Riepe (michael@stud.uni-hannover.de)
Tue, 1 Sep 1998 15:06:00 +0200


On Tue, Sep 01, 1998 at 12:46:49AM -0600, Michal Jaegermann wrote:
[...]
> /* Yes, Virginia, it had better be unsigned */
> unsigned char c1, c2;
[...]
> "return (c1 - c2);" should be ok to safisfy specs, but if you insists
> on returning a sign replace this with:
> c1 =- c2;
> return c1 ? (c1 < 0 ? -1 : 1) : 0;

`c1 < 0' will always be false when `c1' is unsigned. My solution would be

return (int)c1 - (int)c2;

where the `(int)' is, in fact, syntactic sugar.

-- 
 Michael "Tired" Riepe <Michael.Riepe@stud.uni-hannover.de>
 "All I wanna do is have a little fun before I die"

- 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.altern.org/andrebalsa/doc/lkml-faq.html