Re: Identify true error value for kernel API's like kmalloc() and ioremap()

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

 



On Mon, 23 Feb 2015 15:37:52 +0900, manty kuma said:

> If the call fails, the return value is NULL. So, how do I know what caused
> the failure? I have looked at examples in the kernel code. They are
> returning a hard-coded value of -ENOMEM if kmalloc() fails.

Well.. say you call kmalloc() and it fails.  Does it *matter* what caused
the failure?  What are the chances that there is (a) more than one reason
for it to fail, and (b) the error is recoverable in one case but not in
another?

Similarly for ioremap() - under what conditions will the *reason* make a
difference?

Unless you plan to take different action and manage to recover based on
the reason, *it doesn't matter*.  And given the semantics of kmalloc()
and ioremap() specifically, if your code's action will differ based on
the reason, you're probably using the wrong API.....

Attachment: pgpRUUt3K5TLI.pgp
Description: PGP signature

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux