[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20070923160750.GO4887@ghostprotocols.net>
Date: Sun, 23 Sep 2007 13:07:50 -0300
From: Arnaldo Carvalho de Melo <acme@...stprotocols.net>
To: Dave Jones <davej@...hat.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Arjan van de Ven <arjan@...radead.org>,
Cyrill Gorcunov <gorcunov@...il.com>,
LKML <linux-kernel@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Ingo Molnar <mingo@...e.hu>
Subject: Re: memset as memzero
Em Sun, Sep 23, 2007 at 11:32:43AM -0400, Dave Jones escreveu:
> On Sat, Sep 22, 2007 at 11:53:53AM -0700, Linus Torvalds wrote:
> >
> >
> > On Sat, 22 Sep 2007, Arjan van de Ven wrote:
> > >
> > > it doesn't add value.... memset with a constant 0 is just as fast
> > > (since the compiler knows it's 0) than any wrapper around it, and the
> > > syntax around it is otherwise the same.
> >
> > Indeed.
> >
> > The reason we have "clear_page()" is not because the value we're writing
> > is constant - that doesn't really help/change anything at all. We could
> > have had a "fill_page()" that sets the value to any random byte, it's just
> > that zero is the only value that we really care about.
> >
> > So the reason we have "clear_page()" is because the *size* and *alignment*
> > is constant and known at compile time, and unlike the value you write,
> > that actually matters.
> >
> > So "memzero()" would never really make sense as anything but a syntactic
> > wrapper around "memset(x,0,size)".
>
> There is one useful argument for memzero (or bzero to give it its proper
> name), and that's that it's impossible to screw up.
> I'm still amazed at how many times I see
>
> memset (x,size,0);
>
> in various code. So much so, that my editor highlights it now to spot
> it during code review. As does my mail client. To be on the safe
> side, I also have a cron job grepping for it in my ~/Mail/commits
> for all the projects I'm interested in.
>
> It's tragic really just how easy it is to screw it up.
bzero! That is it, its nothing new, just a sane name to something that
is useful to humans, even being of sheer arrogant disdain for machines
as a useless stuff only humans couldn't get right. Yeah, us screw up
pretty much more than them.
- Arnaldo
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists