Check the return value of ftruncate(), mostly to stop Ubuntu 12.04's
[sgt/agedu] / agedu.c
diff --git a/agedu.c b/agedu.c
index 7fd2314..411ae6a 100644 (file)
--- a/agedu.c
+++ b/agedu.c
@@ -1246,7 +1246,8 @@ int main(int argc, char **argv)
                indexbuild_free(ib);
 
                munmap(mappedfile, totalsize);
-               ftruncate(fd, realsize);
+               if (ftruncate(fd, realsize) < 0)
+                    fatal("%s: truncate: %s\n", filename, strerror(errno));
                close(fd);
                printf("Final index file size = %llu bytes\n",
                       (unsigned long long)realsize);