From: Daniel Hokka Zakrisson Date: Mon, 16 Jun 2008 11:32:49 +0000 (+0000) Subject: On failure, mmap returns MAP_FAILED, not 0. X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e0bd9d55bfe2296e898dcae40abee65ad64c6615;p=util-vserver.git On failure, mmap returns MAP_FAILED, not 0. git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2718 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- diff --git a/lib_internal/unify-copy.c b/lib_internal/unify-copy.c index 6c26059..6fe282d 100644 --- a/lib_internal/unify-copy.c +++ b/lib_internal/unify-copy.c @@ -132,8 +132,8 @@ copyMMap(int in_fd, int out_fd) buf_size = in_len - offset; if (buf_size > MMAP_BLOCKSIZE) buf_size = MMAP_BLOCKSIZE; - if ((in_buf = mmap(0, buf_size, PROT_READ, MAP_SHARED, in_fd, offset))==0 || - (out_buf = mmap(0, buf_size, PROT_WRITE, MAP_SHARED, out_fd, offset))==0) { + if ((in_buf = mmap(0, buf_size, PROT_READ, MAP_SHARED, in_fd, offset))==MAP_FAILED || + (out_buf = mmap(0, buf_size, PROT_WRITE, MAP_SHARED, out_fd, offset))==MAP_FAILED) { perror("mmap()"); goto out; } diff --git a/src/check-unixfile.c b/src/check-unixfile.c index a17a064..7a45f88 100644 --- a/src/check-unixfile.c +++ b/src/check-unixfile.c @@ -73,7 +73,7 @@ checkFile(char const *fname) } else if (l>0) { data = mmap(0, l, PROT_READ, MAP_PRIVATE, fd, 0); - if (data==0) { + if (data==MAP_FAILED) { perror("mmap()"); exit(wrapper_exit_code); } diff --git a/src/h2ext.c b/src/h2ext.c index af1cc5a..84fce77 100644 --- a/src/h2ext.c +++ b/src/h2ext.c @@ -148,7 +148,7 @@ process_file(file_format_t *head, const char *file, file_format_t *ret[2]) fd = EopenD(file, O_RDONLY, 0); Efstat(fd, &st); mapping = mmap(NULL, MIN(st.st_size, MAX_PEEK_SIZE), PROT_READ, MAP_SHARED, fd, 0); - if (!mapping) { + if (mapping == MAP_FAILED) { perror("mmap()"); Eclose(fd); return -1; diff --git a/src/testsuite/hashcalc-plain.c b/src/testsuite/hashcalc-plain.c index 16ce2c8..b8dc8c6 100644 --- a/src/testsuite/hashcalc-plain.c +++ b/src/testsuite/hashcalc-plain.c @@ -76,7 +76,7 @@ int main(int UNUSED argc, char *argv[]) void const * buf; if (buf_size>HASH_BLOCKSIZE) buf_size = HASH_BLOCKSIZE; - assert((buf=mmap(0, buf_size, PROT_READ, MAP_SHARED, fd, offset))!=0); + assert((buf=mmap(0, buf_size, PROT_READ, MAP_SHARED, fd, offset))!=MAP_FAILED); offset += buf_size; assert(ensc_crypto_hashctx_update(&hash_context, buf, buf_size)!=-1); munmap((void *)(buf), buf_size); diff --git a/src/vhashify.c b/src/vhashify.c index ed13eba..4cfecf7 100644 --- a/src/vhashify.c +++ b/src/vhashify.c @@ -332,7 +332,7 @@ calculateHashFromFD(int fd, HashPath d_path, struct stat const * const st) buf_size = size-offset; if (buf_size>HASH_BLOCKSIZE) buf_size = HASH_BLOCKSIZE; - if ((buf=mmap(0, buf_size, PROT_READ, MAP_SHARED, fd, offset))==0) { + if ((buf=mmap(0, buf_size, PROT_READ, MAP_SHARED, fd, offset))==MAP_FAILED) { perror("mmap()"); goto out; }