Re: [PATCH] [workqueue] check values of pwq and wq inprint_worker_info() before use
From: Tejun Heo
Date: Tue Oct 01 2013 - 18:47:13 EST
On Tue, Oct 01, 2013 at 06:40:23PM -0400, Tejun Heo wrote:
> Because it is using probe_kernel_read() and such test wouldn't mean
> anything? It may be NULL, it may be 1 or full Fs. NULL is just one
> of many illegal pointers which may happen. Why add code which doesn't
> achieve anything when you're explicitly trying to access pointers
> which you know could be invalid? Why is that "clean"? Is "if (p)
> kfree(p)" cleaner than "kfree(p)"?
Here's one general rule of thumb for "cleanliness" - try to do the
minimal because that's something many people can agree on. If people
do stuff which aren't necessary, naturally different people would have
different opinions on what's cleaner / better and inevitably end up
with different choices as the choices made are functionally superflous
none would fail and we'll end up with various variants for the same
thing for no good reason, which is messy. Adding if (p) in front of
probe_kernel_read(p) is inherently superflous and you wouldn't have
any way to enforce or even encourage such practice and the end result
would inevitably be if (p) being sprayed randomly, which is the
opposite of cleanliness.
So, no, please don't add random tests which aren't essential. It is
inherently messy thing to do.
Thanks.
--
tejun
--
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/