Search Linux Wireless

Re: [RFC v6] rfkill: rewrite

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2009-04-30 at 00:19 -0300, Henrique de Moraes Holschuh wrote:

> The return values for rfkill_alloc() are not the same on the stub and
> real functions.  The stub function uses ERR_PTR, while the real
> function uses NULL for any errors.   Please make them do the same
> thing, and it is probably a damn good idea to document in the
> kerneldoc what kind of return values one should expect when you return
> a pointer and the function can fail (i.e. NULL or ERR_PTR).

Actually, I was going to clean this up, and then I noticed you're
wrong. :) Returning ERR_PTR(-ENODEV) is intentional, in the non-RFKILL
case. Imagine a driver like this:

	ASDF
	rf = rfkill_alloc(...)
	if (!rf)
		return -ENOMEM;
	err = rfkill_register(rf);
	if (err) {
		rfkill_destroy(rf);
		return err;
	}
	GHJK

Now, in the non-RFKILL case, this boils down to:
	rf = ERR_PTR(-ENODEV);
	...

and given compiler optimisations will end up like this:
	ASDF
	GHJK

Which is good :)

johannes

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux