Re: Can we drop __must_check from driver_for_each_device()?

From: Paul Bolle
Date: Tue Aug 06 2013 - 16:31:35 EST

On Fri, 2013-08-02 at 08:31 +0800, Greg Kroah-Hartman wrote:
> On Wed, Jul 31, 2013 at 11:35:13PM +0200, Paul Bolle wrote:
> > 2) Please note that if the callback always returns zero,
> > driver_for_each_device() can still return -EINVAL, but only if it was
> > provided a NULL "drv" (a struct device_driver). It sure seems odd to do
> > so. Can that actually happen?
> Possibly.

So driver_for_each_device() really should be NULL "drv" safe. But
wouldn't it therefor be better to make sure the callback functions do
not return -EINVAL themselves, so -EINVAL will always only indicate the
NULL "drv" case?

> > 3) So to me it looks the __must_check attribute of
> > driver_for_each_device() can be dropped. Do you agree?
> Nope, it should be making people think about the return value of the
> function. If they use it or not might be a problem, but I would argue
> that those call-sites must be fixed, as you point out above.

I see. I guess I should try to submit patches that do just that.

> Is this somehow causing a problem that removing the marking would solve
> for you?

The, rather trivial, issue I'd like to fix is this (long standing)
drivers/isdn/hardware/mISDN/hfcpci.c:2298:2: warning: \
ignoring return value of âdriver_for_each_deviceâ, \
declared with attribute warn_unused_result [-Wunused-result]

I've submitted a patch to silence that warning about a year ago (see ). Dave Miller was pretty clear that
that approach wouldn't do. (I've added Dave to the CC, just because I
mentioned him here.)

So, since this warning is still there, I'm looking for another way to
get rid of it.


Paul Bolle

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at