diff mbox series

btrfs: tests: Fix an NULL vs IS_ERR() test

Message ID 20200117053432.k46ftoqf67dezauh@kili.mountain (mailing list archive)
State New, archived
Headers show
Series btrfs: tests: Fix an NULL vs IS_ERR() test | expand

Commit Message

Dan Carpenter Jan. 17, 2020, 5:34 a.m. UTC
The btrfs_alloc_dummy_device() function never returns NULL, it returns
error pointers.

Fixes: 5d9a4f871168 ("btrfs: Add self-tests for btrfs_rmap_block")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 fs/btrfs/tests/extent-map-tests.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Nikolay Borisov Jan. 17, 2020, 7:11 a.m. UTC | #1
On 17.01.20 г. 7:34 ч., Dan Carpenter wrote:
> The btrfs_alloc_dummy_device() function never returns NULL, it returns
> error pointers.
> 
> Fixes: 5d9a4f871168 ("btrfs: Add self-tests for btrfs_rmap_block")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Doh...

Reviewed-by: Nikolay Borisov <nborisov@suse.com>



> ---
>  fs/btrfs/tests/extent-map-tests.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/btrfs/tests/extent-map-tests.c b/fs/btrfs/tests/extent-map-tests.c
> index b7f2c4398e92..70a2f0dc9a78 100644
> --- a/fs/btrfs/tests/extent-map-tests.c
> +++ b/fs/btrfs/tests/extent-map-tests.c
> @@ -490,9 +490,9 @@ static int test_rmap_block(struct btrfs_fs_info *fs_info,
>  	for (i = 0; i < map->num_stripes; i++) {
>  		struct btrfs_device *dev = btrfs_alloc_dummy_device(fs_info);
>  
> -		if (!dev) {
> +		if (IS_ERR(dev)) {
>  			test_err("cannot allocate device");
> -			ret = -ENOMEM;
> +			ret = PTR_ERR(dev);
>  			goto out;
>  		}
>  		map->stripes[i].dev = dev;
>
David Sterba Jan. 17, 2020, 1:55 p.m. UTC | #2
On Fri, Jan 17, 2020 at 08:34:32AM +0300, Dan Carpenter wrote:
> The btrfs_alloc_dummy_device() function never returns NULL, it returns
> error pointers.
> 
> Fixes: 5d9a4f871168 ("btrfs: Add self-tests for btrfs_rmap_block")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks, folded to the original patch.
diff mbox series

Patch

diff --git a/fs/btrfs/tests/extent-map-tests.c b/fs/btrfs/tests/extent-map-tests.c
index b7f2c4398e92..70a2f0dc9a78 100644
--- a/fs/btrfs/tests/extent-map-tests.c
+++ b/fs/btrfs/tests/extent-map-tests.c
@@ -490,9 +490,9 @@  static int test_rmap_block(struct btrfs_fs_info *fs_info,
 	for (i = 0; i < map->num_stripes; i++) {
 		struct btrfs_device *dev = btrfs_alloc_dummy_device(fs_info);
 
-		if (!dev) {
+		if (IS_ERR(dev)) {
 			test_err("cannot allocate device");
-			ret = -ENOMEM;
+			ret = PTR_ERR(dev);
 			goto out;
 		}
 		map->stripes[i].dev = dev;