struct stat statbuf;
int fd = get_fd();
- ftruncate(fd, (off_t)0);
- ftruncate(fd, (off_t)100000);
+ /* should not ignore ftruncate(2)'s return value */
+ if (ftruncate(fd, (off_t)0) < 0) {
+ prterr("trunc_hack: ftruncate(0)");
+ exit(1);
+ }
+ if (ftruncate(fd, (off_t)100000) < 0) {
+ prterr("trunc_hack: ftruncate(100000)");
+ exit(1);
+ }
if (fstat(fd, &statbuf)) {
prterr("trunc_hack: fstat");
statbuf.st_size = -1;
prt("no extend on truncate! not posix!\n");
exit(130);
}
- ftruncate(fd, 0);
+ if (ftruncate(fd, 0) < 0) {
+ prterr("trunc_hack: ftruncate(0) (2nd call)");
+ exit(1);
+ }
}
static char *tf_buf = NULL;