Whamcloud - gitweb
b=20918 improve log warning
[fs/lustre-release.git] / lustre / tests / mmap_sanity.c
index 012c8b9..22ca9bf 100644 (file)
@@ -158,7 +158,11 @@ static int mmap_tst1(char *mnt)
                 perror(mmap_file);
                 return errno;
         }
-        ftruncate(fd, region);
+        if (ftruncate(fd, region) < 0) {
+                perror("ftruncate()");
+                rc = errno;
+                goto out_close;
+        }
 
         ptr = mmap(NULL, region, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
         if (ptr == MAP_FAILED) {
@@ -193,7 +197,11 @@ static int mmap_tst2(char *mnt)
                 perror(mmap_file);
                 return errno;
         }
-        ftruncate(fd, page_size);
+        if (ftruncate(fd, page_size) < 0) {
+                perror("ftruncate()");
+                rc = errno;
+                goto out_close;
+        }
 
         ptr = mmap(NULL, page_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
         if (ptr == MAP_FAILED) {
@@ -250,7 +258,11 @@ static int mmap_tst3(char *mnt)
                 perror(mmap_file);
                 return errno;
         }
-        ftruncate(fd, region);
+        if (ftruncate(fd, region) < 0) {
+                perror("ftruncate()");
+                rc = errno;
+                goto out_close;
+        }
 
         ptr = mmap(NULL, region, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
         if (ptr == MAP_FAILED) {
@@ -328,14 +340,22 @@ static int mmap_tst4(char *mnt)
                 perror(fileb);
                 return errno;
         }
-        ftruncate(fdr, region);
+        if (ftruncate(fdr, region) < 0) {
+                perror("ftruncate()");
+                rc = errno;
+                goto out_close;
+        }
         fdw = open(filea, O_CREAT|O_RDWR, 0600);
         if (fdw < 0) {
                 perror(filea);
                 rc = errno;
                 goto out_close;
         }
-        ftruncate(fdw, region);
+        if (ftruncate(fdw, region) < 0) {
+                perror("ftruncate()");
+                rc = errno;
+                goto out_close;
+        }
         
         ptr = mmap(NULL, region, PROT_READ|PROT_WRITE, MAP_SHARED, fdr, 0);
         if (ptr == MAP_FAILED) {
@@ -494,7 +514,11 @@ static int mmap_tst5(char *mnt)
                 perror(mmap_file);
                 return errno;
         }
-        ftruncate(fd, region);
+        if (ftruncate(fd, region) < 0) {
+                perror("ftruncate()");
+                rc = errno;
+                goto out_close;
+        }
 
         ptr = mmap(NULL, region, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
         if (ptr == MAP_FAILED) {
@@ -549,7 +573,11 @@ static int mmap_tst6(char *mnt)
                 perror(mmap_file);
                 return errno;
         }
-        ftruncate(fd, page_size);
+        if (ftruncate(fd, page_size) < 0) {
+                perror("ftruncate()");
+                rc = errno;
+                goto out;
+        }
 
         fd2 = open(mmap_file2, O_RDWR, 0600);
         if (fd2 < 0) {