Jan Engelhardt
2007-Sep-13 10:11 UTC
[Btrfs-devel] [PATCH 1/2] Make btrfs-progs compile with -fstrict-aliasing (included in -O2) again.
From: Jan Engelhardt <jengelh@computergmbh.de> Make btrfs-progs compile with -fstrict-aliasing (included in -O2) again. This is done by doing a two-step conversion (rather than a one-step). First, the variable goes from type * to void *, and then to implicitly to void **. (Not sure if this is "good practice", but it shuts up the compiler, so it seems the compiler takes into account that we are actually punning it this way.) --- bit-radix.c | 2 +- btrfsck.c | 2 +- extent-tree.c | 10 +++++----- radix-tree.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) Index: btrfs-progs-0.8/bit-radix.c ==================================================================--- btrfs-progs-0.8.orig/bit-radix.c +++ btrfs-progs-0.8/bit-radix.c @@ -186,7 +186,7 @@ int find_first_radix_bit(struct radix_tr unsigned long slot; slot = start / BIT_RADIX_BITS_PER_ARRAY; - ret = radix_tree_gang_lookup(radix, (void **)gang, slot, + ret = radix_tree_gang_lookup(radix, (void *)gang, slot, ARRAY_SIZE(gang)); found = start % BIT_RADIX_BITS_PER_ARRAY; for (i = 0; i < ret && nr > 0; i++) { Index: btrfs-progs-0.8/btrfsck.c ==================================================================--- btrfs-progs-0.8.orig/btrfsck.c +++ btrfs-progs-0.8/btrfsck.c @@ -413,7 +413,7 @@ int check_extent_refs(struct btrfs_root int err = 0; while(1) { - ret = radix_tree_gang_lookup(extent_radix, (void **)rec, 0, + ret = radix_tree_gang_lookup(extent_radix, (void *)rec, 0, ARRAY_SIZE(rec)); if (!ret) break; Index: btrfs-progs-0.8/extent-tree.c ==================================================================--- btrfs-progs-0.8.orig/extent-tree.c +++ btrfs-progs-0.8/extent-tree.c @@ -164,7 +164,7 @@ int btrfs_write_dirty_block_groups(struc btrfs_init_path(&path); while(1) { - ret = radix_tree_gang_lookup_tag(radix, (void **)cache, + ret = radix_tree_gang_lookup_tag(radix, (void *)cache, 0, ARRAY_SIZE(cache), BTRFS_BLOCK_GROUP_DIRTY); if (!ret) @@ -195,7 +195,7 @@ static int update_block_group(struct btr while(total) { ret = radix_tree_gang_lookup(&info->block_group_radix, - (void **)&cache, blocknr, 1); + (void *)&cache, blocknr, 1); if (!ret) return -1; radix_tree_tag_set(&info->block_group_radix, @@ -229,7 +229,7 @@ int btrfs_finish_extent_commit(struct bt while(1) { ret = radix_tree_gang_lookup(&root->fs_info->pinned_radix, - (void **)gang, 0, + (void *)gang, 0, ARRAY_SIZE(gang)); if (!ret) break; @@ -362,7 +362,7 @@ static int del_pending_extents(struct bt while(1) { ret = radix_tree_gang_lookup_tag( &extent_root->fs_info->cache_radix, - (void **)gang, 0, + (void *)gang, 0, ARRAY_SIZE(gang), CTREE_EXTENT_PENDING_DEL); if (!ret) @@ -738,7 +738,7 @@ int btrfs_free_block_groups(struct btrfs while(1) { ret = radix_tree_gang_lookup(&info->block_group_radix, - (void **)cache, 0, + (void *)cache, 0, ARRAY_SIZE(cache)); if (!ret) break; Index: btrfs-progs-0.8/radix-tree.c ==================================================================--- btrfs-progs-0.8.orig/radix-tree.c +++ btrfs-progs-0.8/radix-tree.c @@ -314,7 +314,7 @@ static inline void **__lookup_slot(struc return NULL; if (height == 0 && root->rnode) - return (void **)&root->rnode; + return (void *)&root->rnode; shift = (height-1) * RADIX_TREE_MAP_SHIFT; slot = &root->rnode;
Jan Engelhardt
2007-Sep-13 10:11 UTC
[Btrfs-devel] [PATCH 2/2] Add per-file dependency tracking
From: Jan Engelhardt <jengelh@computergmbh.de> Adds per-file dependency tracking. The dependency archive ".depend" is only created once. Changing a C file's dependencies does not remake .depend, so make will recompile either too few or too many things. Use of per-.c file dependencies that are created and update during compile solve this. --- Makefile | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) Index: btrfs-progs-0.8/Makefile ==================================================================--- btrfs-progs-0.8.orig/Makefile +++ btrfs-progs-0.8/Makefile @@ -6,6 +6,7 @@ objects = ctree.o disk-io.o radix-tree.o # CHECKFLAGS=-D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ -Wbitwise \ -Wuninitialized -Wshadow -Wundef +DEPFLAGS = -Wp,-MMD,$(@D)/.$(@F).d,-MT,$@ INSTALL= install prefix ?= /usr/local @@ -22,16 +23,11 @@ endif .c.o: $(check) $< - $(CC) $(CFLAGS) -c $< + $(CC) $(DEPFLAGS) $(CFLAGS) -c $< all: $(progs) -$(progs): depend - -depend: - @$(CC) -MM $(ALL_CFLAGS) *.c 1> .depend - btrfsctl: btrfsctl.o gcc $(CFLAGS) -o btrfsctl btrfsctl.o @@ -51,12 +47,10 @@ quick-test: $(objects) quick-test.o gcc $(CFLAGS) -o quick-test $(objects) quick-test.o clean : - rm -f $(progs) cscope.out *.o .depend + rm -f $(progs) cscope.out *.o .*.d install: $(progs) $(INSTALL) -m755 -d $(DESTDIR)$(bindir) $(INSTALL) $(progs) $(DESTDIR)$(bindir) -ifneq ($(wildcard .depend),) -include .depend -endif +-include .*.d