On failure, mmap returns MAP_FAILED, not 0.
authorDaniel Hokka Zakrisson <daniel@hozac.com>
Mon, 16 Jun 2008 11:32:49 +0000 (11:32 +0000)
committerDaniel Hokka Zakrisson <daniel@hozac.com>
Mon, 16 Jun 2008 11:32:49 +0000 (11:32 +0000)
git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2718 94cd875c-1c1d-0410-91d2-eb244daf1a30

lib_internal/unify-copy.c
src/check-unixfile.c
src/h2ext.c
src/testsuite/hashcalc-plain.c
src/vhashify.c

index 6c26059..6fe282d 100644 (file)
@@ -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;
       }
index a17a064..7a45f88 100644 (file)
@@ -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);
     }
index af1cc5a..84fce77 100644 (file)
@@ -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;
index 16ce2c8..b8dc8c6 100644 (file)
@@ -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);
index ed13eba..4cfecf7 100644 (file)
@@ -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(<hash>)");
        goto out;
       }