if (xfs_getgeom(fsfd, &fsgeom) < 0 ) {
fsrprintf(_("Skipping %s: could not get XFS geometry\n"),
mntdir);
+ close(fsfd);
return -1;
}
if (lseek64(tfd, 0, SEEK_SET)) {
fsrprintf(_("Couldn't rewind on temporary file\n"));
close(tfd);
+ if (ffd != -1)
+ close(ffd);
free(fbuf);
return -1;
}
fsrprintf(_("No improvement will be made (skipping): %s\n"), fname);
free(fbuf);
close(tfd);
+ if (ffd != -1)
+ close(ffd);
return 1; /* no change/no error */
}
}
free(fbuf);
close(tfd);
+ if (ffd != -1)
+ close(ffd);
return -1;
}
if (nfrags) {
}
}
ftruncate64(tfd, statp->bs_size);
- if (ffd > 0) close(ffd);
+ if (ffd != -1)
+ close(ffd);
fsync(tfd);
free(fbuf);
gettimeofday(&t2, NULL);
closedir(dir);
+ close(dfd);
t2 = tsub(t2, t1);
timestr(&t2, ts, sizeof(ts), 0);
/* new filesystem. add it to the cache */
fdhp = malloc(sizeof(struct fdhash));
if (fdhp == NULL) {
+ close(fd);
errno = ENOMEM;
return -1;
}
if ((fd = open(fname, O_RDONLY)) < 0 || (size = filesize(fd)) < 0) {
fprintf(stderr, _("%s: failed to open %s: %s\n"),
progname, fname, strerror(errno));
- exit(1);
+ goto out_fail;
}
+
buf = malloc(size + 1);
if (read(fd, buf, size) < size) {
fprintf(stderr, _("%s: read failed on %s: %s\n"),
progname, fname, strerror(errno));
- exit(1);
+ goto out_fail;
}
if (buf[size - 1] != '\n') {
fprintf(stderr, _("%s: proto file %s premature EOF\n"),
progname, fname);
- exit(1);
+ goto out_fail;
}
buf[size] = '\0';
/*
(void)getstr(&buf); /* boot image name */
(void)getnum(&buf); /* block count */
(void)getnum(&buf); /* inode count */
+ close(fd);
return buf;
+
+out_fail:
+ close(fd);
+ exit(1);
}
static long
buf = (xfs_bstat_t *)calloc(NBSTAT, sizeof(xfs_bstat_t));
if (!buf) {
perror("calloc");
+ close(fsfd);
return;
}
if ( !(fsxattr.fsx_xflags & XFS_XFLAG_REALTIME) ) {
fprintf(stderr, _("%s: %s is not a realtime file.\n"),
progname, tbuf);
+ close( tofd );
return( -1 );
}
fprintf(stderr, _("%s: %s file extent size is %d, "
"instead of %d.\n"),
progname, tbuf, fsxattr.fsx_extsize, fextsize);
+ close( tofd );
return( -1 );
}
}