public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [Patch] btrfs-image.c: fix return values
@ 2009-01-19 11:27 Américo Wang
  0 siblings, 0 replies; only message in thread
From: Américo Wang @ 2009-01-19 11:27 UTC (permalink / raw)
  To: linux-btrfs


- Exit with non-zero when fail;
- Don't exit in non-main functions, return.

Signed-off-by: WANG Cong <wangcong@zeuux.org>

---
diff --git a/btrfs-image.c b/btrfs-image.c
index 9925bdb..62b3dd8 100644
--- a/btrfs-image.c
+++ b/btrfs-image.c
@@ -741,7 +741,7 @@ static int restore_metadump(const char *input, FILE *out, int num_threads)
 		in = fopen(input, "r");
 		if (!in) {
 			perror("unable to open metadump image");
-			exit(1);
+			return 1;
 		}
 	}
 
@@ -760,7 +760,7 @@ static int restore_metadump(const char *input, FILE *out, int num_threads)
 		if (le64_to_cpu(header->magic) != HEADER_MAGIC ||
 		    le64_to_cpu(header->bytenr) != bytenr) {
 			fprintf(stderr, "bad header in metadump image\n");
-			exit(1);
+			return 1;
 		}
 		ret = add_cluster(cluster, &mdrestore, &bytenr);
 		BUG_ON(ret);
@@ -850,5 +850,5 @@ int main(int argc, char *argv[])
 	else
 		fclose(out);
 
-	exit(0);
+	exit(ret);
 }



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-01-19 11:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-19 11:27 [Patch] btrfs-image.c: fix return values Américo Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox