static int dentfill(char *path, struct entry **dents)
{
- int fd, n, count;
+ int n = 0, count;
ulong num_saved;
struct dirent *dp;
char *namep, *pnb;
if (dirp == NULL)
return 0;
- fd = dirfd(dirp);
-
- n = 0;
+ int fd = dirfd(dirp);
if (cfg.blkorder) {
num_files = 0;
dir_blocks = 0;
if (fstatat(fd, ".", &sb_path, 0) == -1) {
+ closedir(dirp);
printwarn();
return 0;
}
} else
dir_blocks += ent_blocks;
- if (interrupted)
+ if (interrupted) {
+ closedir(dirp);
return n;
+ }
}
} else {
dir_blocks += (cfg.apparentsz ? sb.st_size : sb.st_blocks);
*dents = xrealloc(*dents, total_dents * sizeof(**dents));
if (*dents == NULL) {
free(pnamebuf);
+ closedir(dirp);
errexit();
}
DPRINTF_P(*dents);
pnamebuf = (char *)xrealloc(pnamebuf, namebuflen);
if (pnamebuf == NULL) {
free(*dents);
+ closedir(dirp);
errexit();
}
DPRINTF_P(pnamebuf);
else
num_files = num_saved;
- if (interrupted)
+ if (interrupted) {
+ closedir(dirp);
return n;
+ }
} else {
dentp->blocks = (cfg.apparentsz ? sb.st_size : sb.st_blocks);
dir_blocks += dentp->blocks;