* [PATCH 2/4] btrfs-progs: remove a dead break before usage()
2014-02-13 3:16 [PATCH 1/4] btrfs-progs: use usage() to replace the warning msg on no-arg usage Gui Hecheng
@ 2014-02-13 3:16 ` Gui Hecheng
2014-02-13 3:16 ` [PATCH 3/4] btrfs-progs: cleanup nonsense ret value assignment Gui Hecheng
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Gui Hecheng @ 2014-02-13 3:16 UTC (permalink / raw)
To: linux-btrfs; +Cc: Gui Hecheng
The usage() in help.c calls exit(1), so the break behind is nonsense
and should be removed.
Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
---
cmds-property.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/cmds-property.c b/cmds-property.c
index 3d1f18c..df53f91 100644
--- a/cmds-property.c
+++ b/cmds-property.c
@@ -335,7 +335,6 @@ static void parse_args(int argc, char **argv,
break;
default:
usage(usage_str);
- break;
}
}
--
1.8.1.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 3/4] btrfs-progs: cleanup nonsense ret value assignment
2014-02-13 3:16 [PATCH 1/4] btrfs-progs: use usage() to replace the warning msg on no-arg usage Gui Hecheng
2014-02-13 3:16 ` [PATCH 2/4] btrfs-progs: remove a dead break before usage() Gui Hecheng
@ 2014-02-13 3:16 ` Gui Hecheng
2014-02-13 3:16 ` [PATCH 4/4] btrfs-progs: fix fsck leaks on error returns Gui Hecheng
2014-02-14 17:57 ` [PATCH 1/4] btrfs-progs: use usage() to replace the warning msg on no-arg usage David Sterba
3 siblings, 0 replies; 7+ messages in thread
From: Gui Hecheng @ 2014-02-13 3:16 UTC (permalink / raw)
To: linux-btrfs; +Cc: Gui Hecheng
The "ret" will be soon used to hold the return value of another function,
assign -1 to it before is nonsense.
Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
---
free-space-cache.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/free-space-cache.c b/free-space-cache.c
index 55d7318..bddde24 100644
--- a/free-space-cache.c
+++ b/free-space-cache.c
@@ -291,8 +291,6 @@ static int __load_free_space_cache(struct btrfs_root *root,
return 0;
}
- ret = -1;
-
leaf = path->nodes[0];
header = btrfs_item_ptr(leaf, path->slots[0],
struct btrfs_free_space_header);
--
1.8.1.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/4] btrfs-progs: fix fsck leaks on error returns
2014-02-13 3:16 [PATCH 1/4] btrfs-progs: use usage() to replace the warning msg on no-arg usage Gui Hecheng
2014-02-13 3:16 ` [PATCH 2/4] btrfs-progs: remove a dead break before usage() Gui Hecheng
2014-02-13 3:16 ` [PATCH 3/4] btrfs-progs: cleanup nonsense ret value assignment Gui Hecheng
@ 2014-02-13 3:16 ` Gui Hecheng
2014-02-14 17:30 ` David Sterba
2014-02-14 17:57 ` [PATCH 1/4] btrfs-progs: use usage() to replace the warning msg on no-arg usage David Sterba
3 siblings, 1 reply; 7+ messages in thread
From: Gui Hecheng @ 2014-02-13 3:16 UTC (permalink / raw)
To: linux-btrfs; +Cc: Gui Hecheng
Add close_ctree()s before the "returns" on errors after open_ctree()
Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
---
cmds-check.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/cmds-check.c b/cmds-check.c
index 2911af0..81f65a3 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -6460,6 +6460,7 @@ int cmd_check(int argc, char **argv)
!extent_buffer_uptodate(info->dev_root->node) ||
!extent_buffer_uptodate(info->chunk_root->node)) {
fprintf(stderr, "Critical roots corrupted, unable to fsck the FS\n");
+ close_ctree(info->fs_root);
return -EIO;
}
@@ -6467,11 +6468,14 @@ int cmd_check(int argc, char **argv)
if (init_extent_tree) {
printf("Creating a new extent tree\n");
ret = reinit_extent_tree(info);
- if (ret)
+ if (ret) {
+ close_ctree(root);
return ret;
+ }
}
if (!extent_buffer_uptodate(info->extent_root->node)) {
fprintf(stderr, "Critical roots corrupted, unable to fsck the FS\n");
+ close_ctree(root);
return -EIO;
}
@@ -6483,12 +6487,14 @@ int cmd_check(int argc, char **argv)
trans = btrfs_start_transaction(info->csum_root, 1);
if (IS_ERR(trans)) {
fprintf(stderr, "Error starting transaction\n");
+ close_ctree(root);
return PTR_ERR(trans);
}
ret = btrfs_fsck_reinit_root(trans, info->csum_root, 0);
if (ret) {
fprintf(stderr, "crc root initialization failed\n");
+ close_ctree(root);
return -EIO;
}
--
1.8.1.4
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 4/4] btrfs-progs: fix fsck leaks on error returns
2014-02-13 3:16 ` [PATCH 4/4] btrfs-progs: fix fsck leaks on error returns Gui Hecheng
@ 2014-02-14 17:30 ` David Sterba
2014-02-17 1:16 ` Gui Hecheng
0 siblings, 1 reply; 7+ messages in thread
From: David Sterba @ 2014-02-14 17:30 UTC (permalink / raw)
To: Gui Hecheng; +Cc: linux-btrfs
On Thu, Feb 13, 2014 at 11:16:38AM +0800, Gui Hecheng wrote:
> @@ -6460,6 +6460,7 @@ int cmd_check(int argc, char **argv)
> !extent_buffer_uptodate(info->dev_root->node) ||
> !extent_buffer_uptodate(info->chunk_root->node)) {
> fprintf(stderr, "Critical roots corrupted, unable to fsck the FS\n");
> + close_ctree(info->fs_root);
> return -EIO;
Can you please convert it to the 'goto + single return' pattern?
The other patches are ok, adding them to integration.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 4/4] btrfs-progs: fix fsck leaks on error returns
2014-02-14 17:30 ` David Sterba
@ 2014-02-17 1:16 ` Gui Hecheng
0 siblings, 0 replies; 7+ messages in thread
From: Gui Hecheng @ 2014-02-17 1:16 UTC (permalink / raw)
To: dsterba; +Cc: linux-btrfs
On Fri, 2014-02-14 at 18:30 +0100, David Sterba wrote:
> On Thu, Feb 13, 2014 at 11:16:38AM +0800, Gui Hecheng wrote:
> > @@ -6460,6 +6460,7 @@ int cmd_check(int argc, char **argv)
> > !extent_buffer_uptodate(info->dev_root->node) ||
> > !extent_buffer_uptodate(info->chunk_root->node)) {
> > fprintf(stderr, "Critical roots corrupted, unable to fsck the FS\n");
> > + close_ctree(info->fs_root);
> > return -EIO;
>
> Can you please convert it to the 'goto + single return' pattern?
Thanks for your comments, David. I'll rework it soon.
Gui
> The other patches are ok, adding them to integration.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/4] btrfs-progs: use usage() to replace the warning msg on no-arg usage
2014-02-13 3:16 [PATCH 1/4] btrfs-progs: use usage() to replace the warning msg on no-arg usage Gui Hecheng
` (2 preceding siblings ...)
2014-02-13 3:16 ` [PATCH 4/4] btrfs-progs: fix fsck leaks on error returns Gui Hecheng
@ 2014-02-14 17:57 ` David Sterba
3 siblings, 0 replies; 7+ messages in thread
From: David Sterba @ 2014-02-14 17:57 UTC (permalink / raw)
To: Gui Hecheng; +Cc: linux-btrfs
On Thu, Feb 13, 2014 at 11:16:35AM +0800, Gui Hecheng wrote:
> --- a/cmds-receive.c
> +++ b/cmds-receive.c
> @@ -951,10 +951,8 @@ int cmd_receive(int argc, char **argv)
> }
> }
>
> - if (optind + 1 != argc) {
> - fprintf(stderr, "ERROR: receive needs path to subvolume\n");
> - return 1;
> - }
> + if (optind + 1 != argc)
FYI, I've replaced this with check_argc_exact
> + usage(cmd_receive_usage);
>
> tomnt = argv[optind];
>
^ permalink raw reply [flat|nested] 7+ messages in thread