From: David Sterba <dsterba@suse.cz>
To: "Luís Henriques" <lhenriques@suse.de>
Cc: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
David Sterba <dsterba@suse.com>,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] btrfs: turn unpin_extent_cache() into a void function
Date: Thu, 20 Jul 2023 13:04:38 +0200 [thread overview]
Message-ID: <20230720110438.GU20457@twin.jikos.cz> (raw)
In-Reply-To: <20230718173906.12568-1-lhenriques@suse.de>
On Tue, Jul 18, 2023 at 06:39:06PM +0100, Luís Henriques wrote:
> The value of the 'ret' variable is never changed in function
> unpin_extent_cache(). And since the only caller of this function doesn't
> check the return value, it can simply be turned into a void function.
>
> Signed-off-by: Luís Henriques <lhenriques@suse.de>
> ---
> fs/btrfs/extent_map.c | 7 ++-----
> fs/btrfs/extent_map.h | 2 +-
> 2 files changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c
> index 0cdb3e86f29b..f99c458071a4 100644
> --- a/fs/btrfs/extent_map.c
> +++ b/fs/btrfs/extent_map.c
> @@ -292,10 +292,9 @@ static void try_merge_map(struct extent_map_tree *tree, struct extent_map *em)
> * to the generation that actually added the file item to the inode so we know
> * we need to sync this extent when we call fsync().
> */
> -int unpin_extent_cache(struct extent_map_tree *tree, u64 start, u64 len,
> - u64 gen)
> +void unpin_extent_cache(struct extent_map_tree *tree, u64 start, u64 len,
> + u64 gen)
> {
> - int ret = 0;
> struct extent_map *em;
> bool prealloc = false;
>
> @@ -327,8 +326,6 @@ int unpin_extent_cache(struct extent_map_tree *tree, u64 start, u64 len,
> free_extent_map(em);
> out:
> write_unlock(&tree->lock);
> - return ret;
> -
> }
This function has unfortunatelly attracting attention to do a simple fix
to just return void, several have been aleary sent but none of them
fixes it properly. To the point I don't want to reply anymore.
https://lore.kernel.org/linux-btrfs/20180815124425.GM24025@twin.jikos.cz/
https://lore.kernel.org/linux-btrfs/20230530150359.GS575@twin.jikos.cz/
https://patchwork.kernel.org/project/linux-btrfs/patch/20190416055739.25771-1-wqu@suse.com/#22596309
"When switching a fuction to return void, please check the whole
callgraph for functions that do not properly handler errors and do
BUG_ON. You won't see errors passed from them so this gives the
impression no error handling is needed in the caller."
prev parent reply other threads:[~2023-07-20 11:11 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-18 17:39 Luís Henriques
2023-07-20 7:12 ` Johannes Thumshirn
2023-07-20 9:13 ` Luís Henriques
2023-07-20 11:04 ` David Sterba [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=20230720110438.GU20457@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=lhenriques@suse.de \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®