free_memory_available()

Erik Elmgren (erik.elmgren@swipnet.se)
Mon, 28 Dec 1998 02:47:00 +0100


Reading through the sources, trying to understand them, I find:

page_alloc.c, line 103
: int free_memory_available(void)
: {
: static int available = 1;
:
: if (nr_free_pages < freepages.low) {
: available = 0;
: return 0;
: }
:
: if (nr_free_pages > freepages.high) {
: available = 1;
: return 2;
: }
:
: return available;
: }

Have I gone mad (unlikely but possible) and there /is/ a reason to assign
a value to a local var and then immediately, unconditionally return?!

If I'm not mad, the above should IM(very)HO be changed to something like:

int free_memory_available(void)
{
if (nr_free_pages < freepages.low)
return 0;

if (nr_free_pages > freepages.high)
return 2;

return 1
}

Regards, Erik

--

"Beware of this code - I have proved it correct, but I haven't tested it!" (-- Knuth?)

- 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.tux.org/lkml/