All of lore.kernel.org
 help / color / mirror / Atom feed
From: Youling Tang <youling.tang@linux.dev>
To: Kent Overstreet <kent.overstreet@linux.dev>
Cc: linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org,
	Youling Tang <tangyouling@kylinos.cn>
Subject: Re: [PATCH] bcachefs: Simplify code in bch2_dev_alloc()
Date: Mon, 14 Oct 2024 09:26:12 +0800	[thread overview]
Message-ID: <6d8fa4ef-e230-4313-bdca-e51a43db0e27@linux.dev> (raw)
In-Reply-To: <4iwneao62n6xuniitihvhp7ojvt2pkjtisnrnax7hyzztyktxm@yn4unwrqqjpb>

Hi, Kent

On 2024/10/13 01:30, Kent Overstreet wrote:

> On Sat, Oct 12, 2024 at 03:59:02PM GMT, Youling Tang wrote:
>> From: Youling Tang <tangyouling@kylinos.cn>
>>
>> - Remove unnecessary variable 'ret'.
>> - Remove unnecessary bch2_dev_free() operations.
>>
>> Signed-off-by: Youling Tang <tangyouling@kylinos.cn>
> the 'goto err' style is more readable when you're staring at tons of
> code
Well.

But 'ret' is not needed here.
Does not execute bch2_dev_free() if the ca in the err path is NULL,
so it can be removed.
Can be modified as follows if necessary:
-- a/fs/bcachefs/super.c
+++ b/fs/bcachefs/super.c
@@ -1352,7 +1352,6 @@ static int bch2_dev_alloc(struct bch_fs *c, 
unsigned dev_idx)
  {
         struct bch_member member = bch2_sb_member_get(c->disk_sb.sb, 
dev_idx);
         struct bch_dev *ca = NULL;
-       int ret = 0;

         if (bch2_fs_init_fault("dev_alloc"))
                 goto err;
@@ -1364,10 +1363,9 @@ static int bch2_dev_alloc(struct bch_fs *c, 
unsigned dev_idx)
         ca->fs = c;

         bch2_dev_attach(c, ca, dev_idx);
-       return ret;
+       return 0;
  err:
-       if (ca)
-               bch2_dev_free(ca);
         return -BCH_ERR_ENOMEM_dev_alloc;

  }

Thanks,
Youling.

      reply	other threads:[~2024-10-14  1:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-12  7:59 [PATCH] bcachefs: Simplify code in bch2_dev_alloc() Youling Tang
2024-10-12 17:30 ` Kent Overstreet
2024-10-14  1:26   ` Youling Tang [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=6d8fa4ef-e230-4313-bdca-e51a43db0e27@linux.dev \
    --to=youling.tang@linux.dev \
    --cc=kent.overstreet@linux.dev \
    --cc=linux-bcachefs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tangyouling@kylinos.cn \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.