From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Ira Weiny <ira.weiny@intel.com>
Cc: nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org,
Dan Williams <dan.j.williams@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Dave Jiang <dave.jiang@intel.com>
Subject: Re: [PATCH v1 1/1] libnvdimm/labels: Get rid of redundant 'else'
Date: Fri, 7 Nov 2025 09:39:17 +0200 [thread overview]
Message-ID: <aQ2iJUZUDf5FLAW-@smile.fi.intel.com> (raw)
In-Reply-To: <690d4178c4d4_29fa161007f@iweiny-mobl.notmuch>
On Thu, Nov 06, 2025 at 06:46:48PM -0600, Ira Weiny wrote:
> Andy Shevchenko wrote:
> > In the snippets like the following
> >
> > if (...)
> > return / goto / break / continue ...;
> > else
> > ...
> >
> > the 'else' is redundant. Get rid of it.
>
> I still need a why to in this commit message.
Sure.
[snip]
...
> > - else if (claim_class == NVDIMM_CCLASS_UNKNOWN) {
> > - /*
> > - * If we're modifying a namespace for which we don't
> > - * know the claim_class, don't touch the existing guid.
> > - */
> > - return target;
> > - } else
> > + if (claim_class == NVDIMM_CCLASS_NONE)
> > return &guid_null;
> > +
> > + /*
> > + * If we're modifying a namespace for which we don't
> > + * know the claim_class, don't touch the existing guid.
> > + */
> > + return target;
>
> This is not an equivalent change.
It's (okau. almost. later on that). The parameter to the function is enum and
the listed values of the enum is all there. The problematic part can be if
somebody supplies an arbitrary value here. Yes, in such a case it will change
behaviour and I think it is correct in my case as UNKNOWN is unknown, and NONE
is actually well known UUID.
...
> > - else if (claim_class == NVDIMM_CCLASS_UNKNOWN) {
> > - /*
> > - * If we're modifying a namespace for which we don't
> > - * know the claim_class, don't touch the existing uuid.
> > - */
> > - return target;
> > - } else
> > + if (claim_class == NVDIMM_CCLASS_NONE)
> > return &uuid_null;
> > +
> > + /*
> > + * If we're modifying a namespace for which we don't
> > + * know the claim_class, don't touch the existing uuid.
> > + */
> > + return target;
>
> This is not an equivalent change.
Same explanation as above. I'll put it into the commit message.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2025-11-07 7:39 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-05 18:37 [PATCH v1 1/1] libnvdimm/labels: Get rid of redundant 'else' Andy Shevchenko
2025-11-05 19:18 ` Ira Weiny
2025-11-06 7:37 ` Andy Shevchenko
2025-11-06 20:57 ` Alison Schofield
2025-11-07 0:46 ` Ira Weiny
2025-11-07 7:39 ` Andy Shevchenko [this message]
2025-11-07 16:23 ` Ira Weiny
2025-11-09 22:11 ` Alison Schofield
2025-11-10 8:50 ` Andy Shevchenko
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=aQ2iJUZUDf5FLAW-@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=ira.weiny@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
--cc=vishal.l.verma@intel.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