lkml.org 
[lkml]   [2006]   [Sep]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Illustration of warning explosion silliness
On Thu, 28 Sep 2006 00:19:36 -0400
Jeff Garzik <jeff@garzik.org> wrote:

> Andrew Morton wrote:
> > And it's not sufficient to say "gee, I can't think of any reason why this
> > handler would return an error, so I'll design its callers to assume that".
> > It is _much_ better to design the callers to assume that callees _can_
> > fail, and to stick the `return 0;' into the terminal callee. Because
> > things can change.
>
> huh? You're going off on a tangent. I agree with the above, just like
> I already agreed that SCSI needs better error checking.

No I'm not. I'm saying that the bugs which this exposed are a far, far
more serious matter than a few false-positive warnings which need
workarounds.

> You're ignoring the API issue at hand. Let me say it again for the
> cheap seats: "search" You search a list, and stick a pointer somewhere
> when found. No hardware touched. No allocations. Real world. There
> is an example of usage in the kernel today.

If it's called in that fashion then the caller should still check the
device_for_each_child() return value to find out if it actually got a
match.

Now it could be that the mysterious caller to which you refer uses the
non-NULLness of some pointer to work out if a match occurred. Well shrug -
add a BUG_ON(!device_for_each_child_return_value) or something.

Or write a new version of device_for_each_child() which returns void and
don't tell anyone about it.

But let's not encourage error-ignoring.

-
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: 2006-09-28 06:39    [from the cache]
©2003-2011 Jasper Spaans