Re: Do not misuse Coverity please (Was: sound/oss/cs46xx.c: fix acheck after use)

From: L. A. Walsh
Date: Mon Mar 28 2005 - 19:00:07 EST




Adrian Bunk wrote:

On Sun, Mar 27, 2005 at 11:21:58PM +0200, Jean Delvare wrote:



There are two cases:
1. NULL is impossible, the check is superfluous
2. this was an actual bug

In the first case, my patch doesn't do any harm (a superfluous isn't a real bug).

In the second case, it fixed a bug.
It might be a bug not many people hit because it might be in some error path of some esoteric driver.

If a maintainer of a well-maintained subsystem like i2c says
"The check is superfluous." that's the perfect solution.

But in less maintained parts of the kernel, even a low possibility that it fixes a possible bug is IMHO worth making such a riskless patch.


---
I'd agree in [al]most any part of the kernel. Unless it
is extremely time critical code, subroutines should expect
possible garbage from their callers.

Just because it may be perfect today doesn't mean someone down
the line won't call the routine with less than perfect parameters.

It used to be called "defensive" programming.

However, in this case, if the author is _certain_ the
pointer can never be NULL, than an "ASSERT(card!=NULL);" might
be appropriate, where ASSERT is a macro that normally compiles
in the check, but could compile to "nothing" for embedded or
kernels that aren't being developed in.

-linda



Thanks,
Jean Delvare



cu
Adrian



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