linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Nikolay Borisov <nborisov@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 2/4] btrfs: Consolidate retval checking of core btree functions
Date: Mon, 17 Dec 2018 17:09:04 +0800	[thread overview]
Message-ID: <3a4e1342-f764-6cee-b76c-e9f1b0167191@gmx.com> (raw)
In-Reply-To: <20181217083602.10166-3-nborisov@suse.com>



On 2018/12/17 下午4:36, Nikolay Borisov wrote:
> Core btree functions in btrfs generally return 0 for error

Isn't 0 for key found? It's <0 for error.

 and 1 in case
> the sought item cannot be found. Consolidate the checks for those
> conditions in one 'if () {} else if () {}' struct rather than 2 separate
> 'if () {}' statements. This emphasizes that the handling code pertains
> to a single function. No functional changes.
> 
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
The code itself is OK, but the commit message is really confusing.

Thanks,
Qu

> ---
>  fs/btrfs/inode.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index fe25f66a98d9..511d3b314af2 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -6801,9 +6801,7 @@ struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
>  	if (ret < 0) {
>  		err = ret;
>  		goto out;
> -	}
> -
> -	if (ret != 0) {
> +	} else if (ret > 0) {
>  		if (path->slots[0] == 0)
>  			goto not_found;
>  		path->slots[0]--;
> @@ -6853,8 +6851,7 @@ struct extent_map *btrfs_get_extent(struct btrfs_inode *inode,
>  			if (ret < 0) {
>  				err = ret;
>  				goto out;
> -			}
> -			if (ret > 0)
> +			} else if (ret > 0)
>  				goto not_found;
>  			leaf = path->nodes[0];
>  		}
> 

  parent reply	other threads:[~2018-12-17  9:09 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-17  8:35 [PATCH 0/4] Misc cleanups of btrfs_get_extent Nikolay Borisov
2018-12-17  8:35 ` [PATCH 1/4] btrfs: Rename found_type to extent_type Nikolay Borisov
2018-12-17  8:54   ` Johannes Thumshirn
2018-12-17  9:05   ` Qu Wenruo
2018-12-17  8:36 ` [PATCH 2/4] btrfs: Consolidate retval checking of core btree functions Nikolay Borisov
2018-12-17  8:55   ` Johannes Thumshirn
2018-12-17  8:57     ` Nikolay Borisov
2018-12-17  9:09   ` Qu Wenruo [this message]
2018-12-17  9:23     ` Nikolay Borisov
2018-12-17  9:49   ` [PATCH v2 " Nikolay Borisov
2018-12-17 11:00     ` Qu Wenruo
2018-12-17  8:36 ` [PATCH 3/4] btrfs: Refactor retval handling of btrfs_lookup_file_extent in btrfs_get_extent Nikolay Borisov
2018-12-17  9:07   ` Johannes Thumshirn
2019-01-02 17:05   ` David Sterba
2019-01-02 17:43     ` Nikolay Borisov
2019-01-07 15:22       ` Johannes Thumshirn
2019-01-07 18:46         ` David Sterba
2019-01-08  7:43           ` Nikolay Borisov
2018-12-17  8:36 ` [PATCH 4/4] btrfs: Remove not_found_em label from btrfs_get_extent Nikolay Borisov
2018-12-17  9:08   ` Johannes Thumshirn
2019-01-02 17:08 ` [PATCH 0/4] Misc cleanups of btrfs_get_extent David Sterba

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=3a4e1342-f764-6cee-b76c-e9f1b0167191@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=nborisov@suse.com \
    /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;
as well as URLs for NNTP newsgroup(s).