Re: [BK PATCH] One strdup() to rule them all

From: Jörn Engel
Date: Thu Sep 11 2003 - 11:24:00 EST


On Mon, 25 August 2003 19:49:18 +0200, Andries Brouwer wrote:
> On Mon, Aug 25, 2003 at 01:05:30PM -0400, Jeff Garzik wrote:
>
> > > > +char *strdup(const char *s)
> > > > +{
> > > > + char *rv = kmalloc(strlen(s)+1, GFP_KERNEL);
> > > > + if (rv)
> > > > + strcpy(rv, s);
> > > > + return rv;
> > > > +}
>
> > Unfortunately Linus doesn't like the strdup cleanup, so I don't see this
> > patch going in either :)
>
> When seeing this my objection was: it introduces something with
> a well-known name that uses GFP_KERNEL, so is not suitable everywhere -
> an invitation to mistakes.

Andries, would you still object this function?

char *strdup(const char *s, int flags)
{
char *rv = kmalloc(strlen(s)+1, flags);
if (rv)
strcpy(rv, s);
return rv;
}

strdup(foo, GFP_KERNEL) should give most people enough clue to know
what they are doing.

Jörn

--
But this is not to say that the main benefit of Linux and other GPL
software is lower-cost. Control is the main benefit--cost is secondary.
-- Bruce Perens
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/