lkml.org 
[lkml]   [2005]   [Mar]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Do not misuse Coverity please (Was: sound/oss/cs46xx.c: fix a check after use)


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@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: 2005-04-06 13:31    [from the cache]
©2003-2011 Jasper Spaans