Re: Is `IS_ERR_VALUE` indicates that the return value is invalid?

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

 



Hi

Please find the example to user file open in kernel below.  source file  #linux/sound/sound_firmware.c

struct file* filp;
 
filp = filp_open(fn, 0, 0);
if (IS_ERR(filp))
{
        printk(KERN_INFO "Unable to load '%s'.\n", fn);
        return 0;
}

IS_ERR expand to below example.

#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
    
static inline long __must_check IS_ERR(__force const void *ptr)
{  
    return IS_ERR_VALUE((unsigned long)ptr);
}

-Anand Moon



On Thursday, November 7, 2013 11:24 AM, 乃宏周 <naive231@xxxxxxxxx> wrote:
In kernel source, `IS_ERR_VALUE` is defined:

#define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)

It's usage can be realized literally, but definition is not.
Can I use this macro to determines the kernel API's result is valid?

Example:
if (IS_ERR_VALUE(filp_open(device)))
{
    filp_close(device);
}

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


_______________________________________________
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