summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2013-08-01 13:35:33 +0800
committerDavid Sterba <dsterba@suse.cz>2013-09-03 19:40:50 +0200
commit7ea01da9c878d5223886ee11859f2e91d00a69a0 (patch)
tree9861b150524e2003779ef43cd878c375752c2e41
parenteda2178b995a637529b95e748be9dd9460ec4d89 (diff)
btrfs-progs: Fix the return value of btrfs-map-logical
The ret variant in the main function is not changed so even problems happen, return value is still 0. The patch fixs the minor bug and return 1 if any problems happen. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
-rw-r--r--btrfs-map-logical.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c
index fce65047..d3d3c70b 100644
--- a/btrfs-map-logical.c
+++ b/btrfs-map-logical.c
@@ -122,7 +122,6 @@ int main(int ac, char **av)
int copy = 0;
u64 bytes = 0;
int out_fd = 0;
- int err;
while(1) {
int c;
@@ -190,8 +189,9 @@ int main(int ac, char **av)
out_fd = open(output_file, O_RDWR | O_CREAT, 0600);
if (out_fd < 0)
goto close;
- err = ftruncate(out_fd, 0);
- if (err) {
+ ret = ftruncate(out_fd, 0);
+ if (ret) {
+ ret = 1;
close(out_fd);
goto close;
}
@@ -208,8 +208,9 @@ int main(int ac, char **av)
while (bytes > 0) {
eb = debug_read_block(root, logical, root->sectorsize, copy);
if (eb && output_file) {
- err = write(out_fd, eb->data, eb->len);
- if (err < 0 || err != eb->len) {
+ ret = write(out_fd, eb->data, eb->len);
+ if (ret < 0 || ret != eb->len) {
+ ret = 1;
fprintf(stderr, "output file write failed\n");
goto out_close_fd;
}