lkml.org 
[lkml]   [2007]   [Jun]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC] [PATCH] cpuset operations causes Badness at mm/slab.c:777 warning


On Fri, 1 Jun 2007, Christoph Lameter wrote:
>
> On Fri, 1 Jun 2007, Andrew Morton wrote:
>
> > I think it'd be better if we kept the WARN_ON_ONCE(size == 0) in there,
>
> The trouble with the WARN_ON is that it triggers even for code that is
> okay like noted by Jeremy.

Yes. Sometimes it's just more natural to have

ptr = kmalloc(size);
.. use it ..
free(ptr);

and if a *degenerate* case of size=0 happens, who cares? It should just
work, as long as we (obviously) don't actually try to access the pointer.

So I don't much like the WARN_ON(size == 0). I think it potentially just
causes people to write around it, and quite possibly causes the callers to
write code that is not at all more readable or maintainable!

That's why I'd much rather return BADPTR instead: we'll get an oops for
buggy code, but we don't penalize the "natural" and good code! So once you
return BADPTR, there really isn't any good reason for the WARN_ON.

Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2007-06-02 03:07    [W:0.084 / U:0.436 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site