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

Michal Jaegermann (michal@ellpspace.math.ualberta.ca)
Tue, 1 Sep 1998 09:18:39 -0600 (MDT)


Gabriel Paubert wrote:
>
> On Tue, 1 Sep 1998, Michal Jaegermann wrote:
>
> > "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 being unsigned, it is unlikely to be negative :-)

All right, all right! Everybody chill out. :-) So writing even
a short code at one in the morning is not the best time for me. :-)
A trivial to repair by a single cast. "return (c1 - c2)" happens
to do a right thing because of a type of the function but I confess
that I was not thinking in these terms.

If you will re-read the context you may discover that I was responding
mostly to a comment about "cool gotos" which did not look to me cool at
all (not because of their presence, but because of a resulting tangle).
Whatever.... Computing return values was truly secondary here even if
I agree that it should be done right. :-)

Interesting that nobody commented on curious effects of passing 'len = -1'
as an argument to the original; especially if you are comparing something
not null-terminated. Not an intended usage, but accidents do happen.

Michal

-
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