return negative number for unsigned long function in kernel

Chen, Dongliang
2007-03-06T16:35:39Z

There are lots of functions in the Linux kernel that are declared as
unsigned long, but the return value is negative integer while error
occurred. An example of these functions is do_mmap_pgoff in mm/mmap.c,
which is defined as:

unsigned long do_mmap_pgoff(....)

In this function, it returns -ENODEV, -EPERM, -ENOMEM, -EINVAL, -EAGAIN,
-EACCESS depends on the error type. My question is how should the caller
perform error check based on the return value?

Please CC reply to me at chen.d@ems-t.com

Thanks,

Dongliang Chen

Staff Engineer
EMS Technologies, Inc - Defense and Space Systems
660 Engineering Dr
Norcross, GA 30092
Tel: 770-263-9200 x 4379