From: Jeff Mahoney <jeffm@suse.com>
To: Andrey Kuzmin <andrey.v.kuzmin@gmail.com>
Cc: Dan Carpenter <error27@gmail.com>,
chris.mason@oracle.com, linux-btrfs@vger.kernel.org
Subject: Re: [patch] error handling of ERR_PTR() returns
Date: Tue, 07 Apr 2009 10:46:03 -0400 [thread overview]
Message-ID: <49DB672B.7070007@suse.com> (raw)
In-Reply-To: <2a31deca0904070734y3f4c3366h5772c032381b38cc@mail.gmail.com>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Andrey Kuzmin wrote:
> Since both NULL ptr and IS_ERR(ptr) are treated as error, why not
> redefine IS_ERR to handle both, simplifying caller's life?
IS_ERR is a global kernel function, and NULL isn't always an error.
- -Jeff
> On Tue, Apr 7, 2009 at 5:38 PM, Dan Carpenter <error27@gmail.com> wrote:
>> There are a couple functions which return ERR_PTR as well as NULL. The
>> caller needs to handle both.
>>
>> Smatch also complains about the handling of alloc_extent_map() but as far
>> as I can see that doesn't actually return an ERR_PTR.
>>
>> Compile tested on 2.6.29.
>>
>> regards,
>> dan carpenter
>>
>> --- orig/fs/btrfs/disk-io.c 2009-04-07 16:15:36.000000000 +0300
>> +++ devel/fs/btrfs/disk-io.c 2009-04-07 16:23:33.000000000 +0300
>> @@ -123,7 +123,7 @@
>>
>> spin_lock(&em_tree->lock);
>> em = lookup_extent_mapping(em_tree, start, len);
>> - if (em) {
>> + if (!IS_ERR(em) && em) {
>> em->bdev =
>> BTRFS_I(inode)->root->fs_info->fs_devices->latest_bdev;
>> spin_unlock(&em_tree->lock);
>> @@ -1216,8 +1216,8 @@
>> int ret;
>>
>> root = btrfs_read_fs_root_no_name(fs_info, location);
>> - if (!root)
>> - return NULL;
>> + if (!root || IS_ERR(root))
>> + return root;
>>
>> if (root->in_sysfs)
>> return root;
>> @@ -1324,7 +1324,7 @@
>> spin_lock(&em_tree->lock);
>> em = lookup_extent_mapping(em_tree, offset, PAGE_CACHE_SIZE);
>> spin_unlock(&em_tree->lock);
>> - if (!em) {
>> + if (!em || IS_ERR(em)) {
>> __unplug_io_fn(bdi, page);
>> return;
>> }
>> --
>> 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
>>
> --
> 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
- --
Jeff Mahoney
SUSE Labs
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iEYEARECAAYFAknbZysACgkQLPWxlyuTD7K0IQCgiZSrwJWtZCG3uRDAKjEPTBeT
qX8AnjaMRgZ9mqw6icQlGNCfOeYGHvO7
=d73O
-----END PGP SIGNATURE-----
prev parent reply other threads:[~2009-04-07 14:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-07 13:38 [patch] error handling of ERR_PTR() returns Dan Carpenter
2009-04-07 14:34 ` Andrey Kuzmin
2009-04-07 14:46 ` Jeff Mahoney [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49DB672B.7070007@suse.com \
--to=jeffm@suse.com \
--cc=andrey.v.kuzmin@gmail.com \
--cc=chris.mason@oracle.com \
--cc=error27@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox