aboutsummaryrefslogtreecommitdiff
path: root/bfd/cache.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2024-03-13 06:31:28 -0700
committerH.J. Lu <hjl.tools@gmail.com>2024-03-13 06:55:44 -0700
commit2e384d4f44f15e560b2a068e0ed866438aaa7cd7 (patch)
tree57e59d6af7e7a76acfd3879885e399b509b78951 /bfd/cache.c
parent32235d90951b4b7c2976c61a28c30d82cb7a7588 (diff)
downloadgdb-2e384d4f44f15e560b2a068e0ed866438aaa7cd7.zip
gdb-2e384d4f44f15e560b2a068e0ed866438aaa7cd7.tar.gz
gdb-2e384d4f44f15e560b2a068e0ed866438aaa7cd7.tar.bz2
bfd: Use MAP_FAILED for mmap failure
Use MAP_FAILED, instead of ((void *) -1), for mmap failure and use ((void *) -1) only if MAP_FAILED is undefined. * bfdio.c (bfd_mmap): Replace (void *) -1 with MAP_FAILED for mmap failure. * bfdwin.c: Don't include <sys/mman.h>. (MAP_FILE): Removed. (bfd_get_file_window): Replace (void *) -1 with MAP_FAILED for mmap failure. * cache.c: Don't include <sys/mman.h>. (cache_bmmap): Replace (void *) -1 with MAP_FAILED for mmap failure. * opncls.c (opncls_bmmap): Likewise. * sysdep.h: Include <sys/mman.h> if HAVE_MMAP is define. (MAP_FILE): New. Defined as 0 if undefined. (MAP_FAILED): New. Defined as ((void *) -1) if undefined.
Diffstat (limited to 'bfd/cache.c')
-rw-r--r--bfd/cache.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/bfd/cache.c b/bfd/cache.c
index 4c00c00..3bc2afc 100644
--- a/bfd/cache.c
+++ b/bfd/cache.c
@@ -45,10 +45,6 @@ SUBSECTION
#include "libbfd.h"
#include "libiberty.h"
-#ifdef HAVE_MMAP
-#include <sys/mman.h>
-#endif
-
static FILE *_bfd_open_file_unlocked (bfd *abfd);
/* In some cases we can optimize cache operation when reopening files.
@@ -489,7 +485,7 @@ cache_bmmap (struct bfd *abfd ATTRIBUTE_UNUSED,
void **map_addr ATTRIBUTE_UNUSED,
bfd_size_type *map_len ATTRIBUTE_UNUSED)
{
- void *ret = (void *) -1;
+ void *ret = MAP_FAILED;
if (!bfd_lock ())
return ret;
@@ -518,7 +514,7 @@ cache_bmmap (struct bfd *abfd ATTRIBUTE_UNUSED,
pg_len = (len + (offset - pg_offset) + pagesize_m1) & ~pagesize_m1;
ret = mmap (addr, pg_len, prot, flags, fileno (f), pg_offset);
- if (ret == (void *) -1)
+ if (ret == MAP_FAILED)
bfd_set_error (bfd_error_system_call);
else
{
@@ -530,7 +526,7 @@ cache_bmmap (struct bfd *abfd ATTRIBUTE_UNUSED,
#endif
if (!bfd_unlock ())
- return (void *) -1;
+ return MAP_FAILED;
return ret;
}