diff --git a/commands/go.c b/commands/go.c index fb319b3..ecc2ceb 100644 --- a/commands/go.c +++ b/commands/go.c @@ -45,7 +45,7 @@ } addr = memmap(fd, PROT_READ); - if (addr == (void *)-1) { + if (addr == MAP_FAILED) { perror("memmap"); goto out; } diff --git a/commands/md.c b/commands/md.c index 3e83c72..a495fc8 100644 --- a/commands/md.c +++ b/commands/md.c @@ -68,7 +68,7 @@ return 1; map = memmap(fd, PROT_READ); - if (map != (void *)-1) { + if (map != MAP_FAILED) { ret = memory_display(map + start, start, size, mode >> O_RWSIZE_SHIFT, swab); goto out; diff --git a/common/ratp/md.c b/common/ratp/md.c index 9ce7e99..ce343d7 100644 --- a/common/ratp/md.c +++ b/common/ratp/md.c @@ -76,7 +76,7 @@ return -errno; map = memmap(fd, PROT_READ); - if (map != (void *)-1) { + if (map != MAP_FAILED) { memcpy(output, (uint8_t *)(map + start), size); goto out; } diff --git a/crypto/digest.c b/crypto/digest.c index bc6de0b..b653fbb 100644 --- a/crypto/digest.c +++ b/crypto/digest.c @@ -232,7 +232,7 @@ } buf = memmap(fd, PROT_READ); - if (buf == (void *)-1) { + if (buf == MAP_FAILED) { buf = xmalloc(4096); flags = 1; } diff --git a/fs/fs.c b/fs/fs.c index 625ed10..a304bf1 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -533,7 +533,7 @@ { struct fs_driver_d *fsdrv; FILE *f; - void *retp = (void *)-1; + void *retp = MAP_FAILED; int ret; if (check_fd(fd)) diff --git a/include/fs.h b/include/fs.h index 181318f..f1514af 100644 --- a/include/fs.h +++ b/include/fs.h @@ -130,6 +130,8 @@ int protect_file(const char *file, int prot); void *memmap(int fd, int flags); +#define MAP_FAILED ((void *)-1) + #define FILESIZE_MAX ((loff_t)-1) #define PROT_READ 1