summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-05-01 10:22:47 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2008-05-01 10:22:47 -0400
commitf86e8be3f89fe64020aa0bc0d07590aa2ed65250 (patch)
tree8f97d1373c8fd9ffbd39474f5ae38f310a1b782a /utils.c
parent9a34051c5183ef91674420f4326da2390d7e4be6 (diff)
Fix uninitialized variables, and use -O so gcc starts checking for them
Gcc only sends warnings for uninitialized variables when you compile with -O, and there were a couple of bugs sprinkled in the code. The biggest was the alloc_start variable for mkfs, which can cause strange things to happen. (thanks to Gabor Micsko for helping to find this)
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/utils.c b/utils.c
index 2fa3c96c..44a5dc6d 100644
--- a/utils.c
+++ b/utils.c
@@ -645,7 +645,7 @@ int btrfs_register_one_device(char *fname)
int btrfs_scan_one_dir(char *dirname, int run_ioctl)
{
- DIR *dirp;
+ DIR *dirp = NULL;
struct dirent *dirent;
struct pending_dir *pending;
struct stat st;
@@ -734,7 +734,8 @@ again:
ret = 0;
fail:
free(pending);
- closedir(dirp);
+ if (dirp)
+ closedir(dirp);
return ret;
}