gbranden pushed a commit to branch master
in repository groff.

commit e30d07f549e89b060f8e3ecba47713e38fa79e40
Author: G. Branden Robinson <[email protected]>
AuthorDate: Sun Sep 12 04:57:48 2021 +1000

    [libbib]: Fix portability nit.
    
    * src/libs/libbib/map.c (mapread): Compare return value of `mmap()` to
      `MAP_FAILED` instead of `(char *)-1`.  `MAP_FAILED` is documented in
      POSIX Issue 5 a.k.a. SUSv2
      <https://pubs.opengroup.org/onlinepubs/007908799/xsh/mmap.html> {1997}
      and should be portable enough by now.
---
 ChangeLog             | 8 ++++++++
 src/libs/libbib/map.c | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 648f7a1..a1b489a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2021-09-12  G. Branden Robinson <[email protected]>
+
+       * src/libs/libbib/map.c (mapread): Compare return value of
+       `mmap()` to `MAP_FAILED` instead of `(char *)-1`.  `MAP_FAILED`
+       is documented in POSIX Issue 5 a.k.a. SUSv2
+       <https://pubs.opengroup.org/onlinepubs/007908799/xsh/mmap.html>
+       {1997} and should be portable enough by now.
+
 2021-09-11  G. Branden Robinson <[email protected]>
 
        [troff]: Clamp negative tab stop positions to zero instead of
diff --git a/src/libs/libbib/map.c b/src/libs/libbib/map.c
index 5d635af..5710d31 100644
--- a/src/libs/libbib/map.c
+++ b/src/libs/libbib/map.c
@@ -44,7 +44,7 @@ char *mapread(int fd, int nbytes)
 {
   char *p = (char *)mmap((void *)0, (size_t)nbytes, PROT_READ,
                         MAP_FILE|MAP_PRIVATE, fd, (off_t)0);
-  if (p == (char *)-1)
+  if (p == MAP_FAILED)
     return 0;
   /* mmap() shouldn't return 0 since MAP_FIXED wasn't specified. */
   if (p == 0)

_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit

Reply via email to