Re: [PATCH] if (foo) kfree(foo) /fs cleanup + reverted JBD code path

Zwane Mwaikambo (zwane@linux.realnet.co.sz)
Sat, 1 Dec 2001 20:02:25 +0200 (SAST)


You present some good arguments against the patch, i did it initially to
remove the double check and i would think the most common path would be a
kfree in any case (I can't back this up with proof) so its not that
expensive, so instead of;

if (foo) {
kfree(foo);
foo = NULL;
}
frob();

we can /* as whoever wrote kfree intended */

kfree(foo);
foo = NULL;
frob();

I would think in any case if we were looking at optimisation, the
assignment is roughly on par with the compare and saves you a bit on the
other case.

Alan Cox also suggested the BUG() trigger in there, with the
resultant breakage that would bring about. But i think its ok as long as
you don't call kfree with uninitialised variables or some such or forget
to set them to NULL at some point.

Thanks,
Zwane Mwaikambo

-
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/