This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [open-source] Re: Wish for 2002 ...



On Fri, 11 Jan 2002, Markus Friedl wrote:

> On Thu, Jan 10, 2002 at 04:37:27PM -0800, Paul Eggert wrote:
> > 	len = strlen(challenge) + strlen(PROMPT) + 1;
> > 	p = xmalloc(len);
> > 	p[0] = '\0';
> > 	strlcat(p, challenge, len);
> > 	strlcat(p, PROMPT, len);
> >
> > Here, the use of strlcat is redundant: strcat would do just as well,
> > and would be clearer, smaller, and no doubt faster.
> >
> > I expect your other examples are similar.
>
> The code will not be converted to use strcat().

Nobody sane would convert it to strcat. The above code is CRAP.

Who the h*ll is the idiot that does "concatenate the empty string with
that string that I just took the length of", and then argues about strcat
vs strlcat?

Hello? Wake up. That code is _stupid_. It was a bit slow to use strcat in
the first place (you _know_ the length of the string), but at least it was
portable and simple, and "strcpy+strcat" at least makes sense.

But then to use a non-portable "strlcat" to concatenate an empty string,
that's just silly.

And then to try to _advocate_ being silly is just incomprehensible.

The above code is slow, ugly, non-straightforward, unportable and no more
secure than the original code was.

In short, it is just stupid code.

But hey, if you want to advocate stupid code in public, that's your
prerogative. But please don't be proud of it.

		Linus


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]