[Tux3] valgrind happiness :)

Pranith Kumar bobby.prani at gmail.com
Thu Nov 27 02:33:19 PST 2008


Convert return in main() to exit for valgrind.

diff -r aa929a08a49b user/balloc.c
--- a/user/balloc.c	Thu Nov 27 15:36:56 2008 +0900
+++ b/user/balloc.c	Thu Nov 27 16:01:00 2008 +0530
@@ -99,6 +99,6 @@ int main(int argc, char *argv[])
 	bfree(sb, 0x7e);
 	bfree(sb, 0x80);
 	bitmap_dump(bitmap, 0, from_be_u64(sb->super.volblocks));
-	return 0;
+	exit(0);
 }
 #endif
diff -r aa929a08a49b user/btree.c
--- a/user/btree.c	Thu Nov 27 15:36:56 2008 +0900
+++ b/user/btree.c	Thu Nov 27 16:01:00 2008 +0530
@@ -159,7 +159,7 @@ int main(int argc, char *argv[])
 			uleaf_insert(&btree, bufdata(buffer), i, i + 0x100);
 		mark_buffer_dirty(buffer);
 		uleaf_dump(&btree, bufdata(buffer));
-		return 0;
+		exit(0);
 	}

 	struct cursor cursor[30];
@@ -175,6 +175,6 @@ int main(int argc, char *argv[])
 	show_buffers(sb->devmap);
 	tree_chop(&btree, &(struct delete_info){ .key = 0x10 }, -1);
 	show_tree_range(&btree, 0, -1);
-	return 0;
+	exit(0);
 }
 #endif
diff -r aa929a08a49b user/buffer.c
--- a/user/buffer.c	Thu Nov 27 15:36:56 2008 +0900
+++ b/user/buffer.c	Thu Nov 27 16:01:00 2008 +0530
@@ -508,5 +508,5 @@ int buffer_main(int argc, char *argv[])
 	printf("get %p\n", blockget(map, 1));
 	printf("get %p\n", blockget(map, 2));
 	printf("get %p\n", blockget(map, 1));
-	return 0;
+	exit(0);
 }
diff -r aa929a08a49b user/dir.c
--- a/user/dir.c	Thu Nov 27 15:36:56 2008 +0900
+++ b/user/dir.c	Thu Nov 27 16:01:00 2008 +0530
@@ -123,5 +123,5 @@ int main(int argc, char *argv[])
 	char dents[10000];
 	tux_readdir(file, dents, filldir);
 	show_buffers(map);
-	return 0;
+	exit(0);
 }
diff -r aa929a08a49b user/dleaf.c
--- a/user/dleaf.c	Thu Nov 27 15:36:56 2008 +0900
+++ b/user/dleaf.c	Thu Nov 27 16:01:00 2008 +0530
@@ -128,20 +128,19 @@ int main(int argc, char *argv[])
 			assert(memcmp(&w2[i], &w2[i], sizeof(w1[0])) == 0);
 		dleaf_destroy(btree, leaf1);
 	}
-exit(0); // valgrind happiness
 	if (1) {
 		dwalk_probe(leaf, sb->blocksize, walk, 0x1000044);
 		dwalk_back(walk);
 		dwalk_back(walk);
 		for (struct extent *extent; (extent = dwalk_next(walk));)
 			printf("0x%Lx => 0x%Lx\n", (L)dwalk_index(walk), (L)extent_block(*extent));
-		return 0;
+		exit(0);
 	}
 	if (1) {
 		dwalk_probe(leaf, sb->blocksize, walk, 0x1c01c);
 		dwalk_chop(walk);
 		dleaf_dump(btree, leaf);
-		return 0;
+		exit(0);
 	}
 	dleaf_dump(btree, leaf);
 	for (int i = 0; i < sizeof(keys) / sizeof(keys[0]); i++) {
@@ -166,6 +165,6 @@ exit(0); // valgrind happiness
 	dleaf_dump(btree, leaf);
 	dleaf_destroy(btree, leaf);
 	dleaf_destroy(btree, dest);
-	return 0;
+	exit(0);
 }
 #endif
diff -r aa929a08a49b user/filemap.c
--- a/user/filemap.c	Thu Nov 27 15:36:56 2008 +0900
+++ b/user/filemap.c	Thu Nov 27 16:01:00 2008 +0530
@@ -83,12 +83,12 @@ int main(int argc, char *argv[])
 	brelse_dirty(blockread(mapping(inode), 0x1));
 	printf("flush... %s\n", strerror(-flush_buffers(mapping(inode))));
 	filemap_extent_io(blockget(mapping(inode), 1), 0);
-	return 0;
+	exit(0);
 #endif

 #if 1
 	filemap_extent_io(blockget(mapping(inode), 5), 0);
-	return 0;
+	exit(0);
 #endif

 #if 0
@@ -108,7 +108,7 @@ int main(int argc, char *argv[])
 	brelse_dirty(blockget(mapping(inode), 7));
 	printf("flush... %s\n", strerror(-flush_buffers(mapping(inode))));

-	return 0;
+	exit(0);
 #endif

 	brelse_dirty(blockget(mapping(inode), 0));
@@ -127,6 +127,7 @@ int main(int argc, char *argv[])
 	printf("flush... %s\n", strerror(-flush_buffers(mapping(inode))));

 	//show_buffers(mapping(inode));
-	return 0;
+	
+	exit(0);
 }
 #endif
diff -r aa929a08a49b user/iattr.c
--- a/user/iattr.c	Thu Nov 27 15:36:56 2008 +0900
+++ b/user/iattr.c	Thu Nov 27 16:01:00 2008 +0530
@@ -43,6 +43,6 @@ int main(int argc, char *argv[])
 	printf("decode %ti attr bytes\n", sizeof(attrs));
 	decode_attrs(inode, attrs, sizeof(attrs));
 	dump_attrs(inode);
-	return 0;
+	exit(0);
 }
 #endif
diff -r aa929a08a49b user/ileaf.c
--- a/user/ileaf.c	Thu Nov 27 15:36:56 2008 +0900
+++ b/user/ileaf.c	Thu Nov 27 16:01:00 2008 +0530
@@ -98,6 +98,6 @@ hexdump(leaf, 16);
 	ileaf_dump(btree, leaf);
 	ileaf_destroy(btree, leaf);
 	ileaf_destroy(btree, dest);
-	return 0;
+	exit(0);
 }
 #endif
diff -r aa929a08a49b user/inode.c
--- a/user/inode.c	Thu Nov 27 15:36:56 2008 +0900
+++ b/user/inode.c	Thu Nov 27 16:01:00 2008 +0530
@@ -199,7 +199,7 @@ int main(int argc, char *argv[])
 	trace("create file");
 	struct inode *inode = tuxcreate(sb->rootdir, "foo", 3, &(struct
tux_iattr){ .mode = S_IFREG | S_IRWXU });
 	if (!inode)
-		return 1;
+		exit(1);
 	tux_dump_entries(blockget(mapping(sb->rootdir), 0));

 	trace(">>> write file");
@@ -230,7 +230,7 @@ int main(int argc, char *argv[])
 	int got = tuxread(file, buf, sizeof(buf));
 	trace_off("got %x bytes", got);
 	if (got < 0)
-		return 1;
+		exit(1);
 	hexdump(buf, got);
 	trace(">>> show state");
 	show_buffers(mapping(file->f_inode));
@@ -238,7 +238,7 @@ int main(int argc, char *argv[])
 	show_buffers(sb->devmap);
 	bitmap_dump(sb->bitmap, 0, sb->volblocks);
 	show_tree_range(&sb->itable, 0, -1);
-	return 0;
+	exit(0);
 eek:
 	return error("Eek! %s", strerror(errno));
 }
diff -r aa929a08a49b user/tux3.c
--- a/user/tux3.c	Thu Nov 27 15:36:56 2008 +0900
+++ b/user/tux3.c	Thu Nov 27 16:01:00 2008 +0530
@@ -254,14 +254,15 @@ int main(int argc, const char *argv[])
 	//show_buffers(sb->rootdir->map);
 	//show_buffers(sb->devmap);
 	poptFreeContext(popt);
+	exit(0);
 	return 0;
 eek:
 	fprintf(stderr, "%s!\n", strerror(errno));
-	return 1;
+	exit(1);
 usage:
 	poptPrintUsage(popt, stderr, 0);
-	return 1;
+	exit(1);
 badopt:
 	fprintf(stderr, "%s: %s\n", poptBadOption(popt,
POPT_BADOPTION_NOALIAS), poptStrerror(c));
-	return 1;
+	exit(1);
 }
diff -r aa929a08a49b user/version.c
--- a/user/version.c	Thu Nov 27 15:36:56 2008 +0900
+++ b/user/version.c	Thu Nov 27 16:01:00 2008 +0530
@@ -910,7 +910,7 @@ int main(int argc, char *argv[])
 	fuzz_test(sb, argc > 1 ? atoi(argv[1]) : 10000);
 //	same_test(sb, 3, 4);
 //	show_heirs(sb, 22);
-	return 0;
+	exit(0);
 #endif

 	tag_t nexttag = 1001;
@@ -919,7 +919,7 @@ int main(int argc, char *argv[])
 	label_t v3 = v3 = new_version(sb, v2, nexttag++);
 	extract_children(sb);
 	show_tree(sb);
-	return 0;
+	exit(0);
 #if 0
 	show_table();
 	extract_children();
@@ -981,7 +981,7 @@ int main(int argc, char *argv[])
 	show_elements(sb);
 	printf("data = 0x%x, orgdata = 0x%x\n", snapshot_read(sb, 1002), orgdata);
 	hexdump(sb->child_index, 16);
-	return 0;
+	exit(0);

 	label_t v4 = v4 = new_version(sb, v1, nexttag++);
 	label_t v5 = v5 = new_version(sb, v4, nexttag++);
diff -r aa929a08a49b user/xattr.c
--- a/user/xattr.c	Thu Nov 27 15:36:56 2008 +0900
+++ b/user/xattr.c	Thu Nov 27 16:01:00 2008 +0530
@@ -141,6 +141,6 @@ int main(int argc, char *argv[])
 		show_buffers(map);
 	}
 	free(inode->xcache); // happy valgrind
-	return 0;
+	exit(0);
 }
 #endif

-- 
Pranith.

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



More information about the Tux3 mailing list