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)
master
Chris Mason 2008-05-01 10:22:47 -04:00 committed by David Woodhouse
parent 9a34051c51
commit f86e8be3f8
4 changed files with 7 additions and 6 deletions

View File

@ -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 \

View File

@ -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;

2
mkfs.c
View File

@ -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();

View File

@ -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;
}