All of lore.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: "Chen, Dongliang" <Chen.D@ems-t.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: return negative number for unsigned long function in kernel
Date: Tue, 06 Mar 2007 16:39:16 -0800	[thread overview]
Message-ID: <45EE09B4.40207@zytor.com> (raw)
In-Reply-To: <314BE1148B8C8D468A05944FDF577583069B021E@MRE02.enterprise.com>

Chen, Dongliang wrote:
> 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? 
> 

If you want to test for errorness, you could use the macro 
IS_ERR_VALUE().  Unfortunately the macro isn't all that safe, in that it 
will give you the wrong answer if it's ever used on something that 
*isn't* an unsigned long.

	-hpa


  parent reply	other threads:[~2007-03-07  0:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-06 14:52 return negative number for unsigned long function in kernel Chen, Dongliang
2007-03-06 19:05 ` Andreas Schwab
2007-03-07  0:39 ` H. Peter Anvin [this message]
2007-03-07 13:31   ` Chen, Dongliang
2007-03-07 16:30     ` H. Peter Anvin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45EE09B4.40207@zytor.com \
    --to=hpa@zytor.com \
    --cc=Chen.D@ems-t.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.