[PATCH 07/14] mkfs.cramfs: use defined failure name rather than magic value

Sami Kerola
2014-07-13T20:25:24Z

>From manual page; 'On error, the value MAP_FAILED is returned, and errno
is set appropriately'.

Reference: http://man7.org/linux/man-pages/man2/mmap.2.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
disk-utils/mkfs.cramfs.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/disk-utils/mkfs.cramfs.c b/disk-utils/mkfs.cramfs.c
index 6f412d8..bae68ec 100644
--- a/disk-utils/mkfs.cramfs.c
+++ b/disk-utils/mkfs.cramfs.c
@@ -167,11 +167,9 @@ do_mmap(char *path, unsigned int size, unsigned int mode){
}

start = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0);
- if (-1 == (int) (long) start) {
- close(fd);
- err(MKFS_EX_ERROR, "mmap");
- }
close(fd);
+ if (start == MAP_FAILED)
+ err(MKFS_EX_ERROR, "mmap");
return start;
err:
free(start);
--
2.0.1