summaryrefslogtreecommitdiff
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
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)
-rw-r--r--Makefile2
-rw-r--r--btrfs-vol.c4
-rw-r--r--mkfs.c2
-rw-r--r--utils.c5
4 files changed, 7 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 7100852e..287ce5ab 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
CC=gcc
AM_CFLAGS = -Wall -fno-strict-aliasing -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2
-CFLAGS = -g -Werror
+CFLAGS = -g -Werror -Os
objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \
root-tree.o dir-item.o hash.o file-item.o inode-item.o \
inode-map.o crc32c.o rbtree.o extent-cache.o extent_io.o \
diff --git a/btrfs-vol.c b/btrfs-vol.c
index 0cc2e979..9eddd782 100644
--- a/btrfs-vol.c
+++ b/btrfs-vol.c
@@ -71,9 +71,9 @@ int main(int ac, char **av)
char *mnt = NULL;
int ret;
int option_index = 0;
- int cmd;
+ int cmd = 0;
int fd;
- int devfd;
+ int devfd = 0;
DIR *dirstream;
struct btrfs_ioctl_vol_args args;
u64 dev_block_count = 0;
diff --git a/mkfs.c b/mkfs.c
index c02627f3..740cc81d 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -308,7 +308,7 @@ int main(int ac, char **av)
u64 block_count = 0;
u64 dev_block_count = 0;
u64 blocks[6];
- u64 alloc_start;
+ u64 alloc_start = 0;
u64 metadata_profile = BTRFS_BLOCK_GROUP_RAID1 | BTRFS_BLOCK_GROUP_DUP;
u64 data_profile = BTRFS_BLOCK_GROUP_RAID0;
u32 leafsize = getpagesize();
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;
}