[Tux3] Initialize rest_limit_adjust before use

OGAWA Hirofumi hirofumi at mail.parknet.co.jp
Tue Dec 30 10:25:26 PST 2008


"Liu XiaoFeng" <bladehliu at gmail.com> writes:

> There is a warning when tux3 is compiled:
> "fs/tux3/dleaf.c:300: warning: 'rest_limit_adjust' may be used uninitialized
> in this function"

Looks like it's the bug of gcc. Which version? (BTW, gcc-4.3 doesn't warn).
Anyway, I'd like to change it like the following instead.

Does the following patch work for your gcc version too?

Thanks.
-- 
OGAWA Hirofumi <hirofumi at mail.parknet.co.jp>



diff -puN user/kernel/dleaf.c~dleaf-cleanup user/kernel/dleaf.c
--- tux3/user/kernel/dleaf.c~dleaf-cleanup	2008-12-31 03:17:33.000000000 +0900
+++ tux3-hirofumi/user/kernel/dleaf.c	2008-12-31 03:18:48.000000000 +0900
@@ -297,7 +297,7 @@ void dleaf_merge(struct btree *btree, vl
 	struct group *group2 = gdict2 - 1;
 	struct group *gstop2 = gdict2 - dleaf_groups(from);
 	struct entry *edict2 = (struct entry *)gstop2;
-	unsigned merge_gcount = 0, rest_gcount = 0, rest_limit_adjust;
+	unsigned merge_gcount = 0, rest_gcount = 0;
 	int can_merge_group = 0;
 
 	assert(dleaf_groups(leaf) >= 1);
@@ -313,7 +313,6 @@ void dleaf_merge(struct btree *btree, vl
 		if (room < gcount2) {
 			/* Calc adjust for the rest of group/entries */
 			rest_gcount = gcount2 - room;
-			rest_limit_adjust = entry_limit(edict2 - room);
 			gcount2 = room;
 		} else
 			can_merge_group = 1;
@@ -353,9 +352,10 @@ void dleaf_merge(struct btree *btree, vl
 			/* adjust the group/entries which couldn't merge */
 			ebase = estop;
 			estop = ebase - rest_gcount;
+			limit_adjust = entry_limit(edict2 - merge_gcount);
 			set_group_count(gstop - 1, rest_gcount);
 			while (--ebase >= estop)
-				inc_entry_limit(ebase, -rest_limit_adjust);
+				inc_entry_limit(ebase, -limit_adjust);
 		}
 	}
 	assert(!dleaf_check(leaf, btree->sb->blocksize));
_

_______________________________________________
Tux3 mailing list
Tux3 at tux3.org
http://mailman.tux3.org/cgi-bin/mailman/listinfo/tux3



More information about the Tux3 mailing list