From: Andreas Schwab <schwab@suse.de>
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 20:05:38 +0100 [thread overview]
Message-ID: <je4poyp4zh.fsf@sykes.suse.de> (raw)
In-Reply-To: <314BE1148B8C8D468A05944FDF577583069B021E@MRE02.enterprise.com> (Dongliang Chen's message of "Tue, 6 Mar 2007 09:52:34 -0500")
"Chen, Dongliang" <Chen.D@ems-t.com> writes:
> 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?
The return value is directly passed to user space (it's the guts of the
mmap syscall). The glibc wrapper transforms it appropriately so that
errno is set and -1 is returned if there is an error.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
next prev parent reply other threads:[~2007-03-06 19:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-06 14:52 Chen, Dongliang
2007-03-06 19:05 ` Andreas Schwab [this message]
2007-03-07 0:39 ` H. Peter Anvin
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=je4poyp4zh.fsf@sykes.suse.de \
--to=schwab@suse.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®