This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][BZ 16074] Document that mmap() returns MAP_FAILED on error


Hello,

At the moment, the glibc manual documents mmap() as returning -1 on error.

This is a problem because (1) it is cumbersome to test whether a void*
return value is equal to an integer and (2) it is not portable.

POSIX states that it returns MAP_FAILED on error as per
http://pubs.opengroup.org/onlinepubs/009695399/functions/mmap.html

I suggest that the manual should be changed to indicate that mmap()
returns MAP_FAILED on error, which it does.

Could you please review the patch?

Thanks!

Best regards
Fabrice

---
 ChangeLog        |    5 +++++
 manual/llio.texi |    4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2027bd6..4912ffd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-10-22  Fabrice Bauzac  <fbauzac@debian71.nce.amadeus.net>
+
+    * manual/llio.texi (Memory-mapped I/O): Indicate that mmap returns
+    MAP_FAILED on error.
+
 2013-05-11  Joseph Myers  <joseph@codesourcery.com>

     * math/libm-test.inc (fma_test): Use max_value instead of local
diff --git a/manual/llio.texi b/manual/llio.texi
index b129cf4..dd0eaa3 100644
--- a/manual/llio.texi
+++ b/manual/llio.texi
@@ -1226,8 +1226,8 @@ as the included @code{malloc} automatically uses
@code{mmap} where appropriate.

 @end vtable

-@code{mmap} returns the address of the new mapping, or @math{-1} for an
-error.
+@code{mmap} returns the address of the new mapping, or
+@code{MAP_FAILED} for an error.

 Possible errors include:

-- 
1.7.10.4

Attachment: 0001-Document-that-mmap-returns-MAP_FAILED-on-error-as-pe.patch
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]