André Nogueira
2010-Aug-09 10:47 UTC
[PATCH] Function btree_get_extent: Incorrect if-else if statement
The btree_get_extent function (in file disk-io.c) calls the add_extent_mapping (in file extent_map.c). The add_extent_mapping function can return two values: 0 or -EEXIST. After the call, it is used an if-else if statement. If the result is -EEXIST, the if statement is executed. If the result is 0, the else if statement will not be executed because it is false. Thank you. Signed-off-by: Andre Nogueira <andre.neo.net@gmail.com> --- fs/btrfs/disk-io.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 34f7c37..76eb161 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -164,7 +164,7 @@ static struct extent_map *btree_get_extent(struct inode *inode, failed_len); ret = -EIO; } - } else if (ret) { + } else { free_extent_map(em); em = NULL; } -- 1.6.3.3
Andre Nogueira
2010-Sep-06 13:51 UTC
Re: [PATCH] Function btree_get_extent: Incorrect if-else if statement
Hi. I sent this patch weeks ago. I would like to have some feedback about it. Thanks in advance. 2010/8/9 André Nogueira <andre.neo.net@gmail.com>:> The btree_get_extent function (in file disk-io.c) calls the > add_extent_mapping (in file extent_map.c). The add_extent_mapping > function can return two values: 0 or -EEXIST. > > After the call, it is used an if-else if statement. If the result is > -EEXIST, the if statement is executed. If the result is 0, the else if > statement will not be executed because it is false. > > Thank you. > > Signed-off-by: Andre Nogueira <andre.neo.net@gmail.com> > > --- > fs/btrfs/disk-io.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c > index 34f7c37..76eb161 100644 > --- a/fs/btrfs/disk-io.c > +++ b/fs/btrfs/disk-io.c > @@ -164,7 +164,7 @@ static struct extent_map *btree_get_extent(struct > inode *inode, > failed_len); > ret = -EIO; > } > - } else if (ret) { > + } else { > free_extent_map(em); > em = NULL; > } > -- > 1.6.3.3 >-- André Nogueira http://sites.google.com/site/andrenogueirasite/ -- 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
Zhu Yanhai
2010-Sep-06 14:15 UTC
Re: [PATCH] Function btree_get_extent: Incorrect if-else if statement
This is not correct. 2010/8/9 André Nogueira <andre.neo.net@gmail.com>:> The btree_get_extent function (in file disk-io.c) calls the > add_extent_mapping (in file extent_map.c). The add_extent_mapping > function can return two values: 0 or -EEXIST.It might return some other error values besides -EEXIST, the ''else if (ret)'' branch is just against them. Namely, we should do some thing special when EEXIST, and do another things for all other errors. Regards, Zhu Yanhai