public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Ira Weiny <ira.weiny@intel.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org
Cc: Dan Williams <dan.j.williams@intel.com>,
	Vishal Verma <vishal.l.verma@intel.com>,
	Dave Jiang <dave.jiang@intel.com>
Subject: [PATCH v1 1/1] libnvdimm/labels: Get rid of redundant 'else'
Date: Wed,  5 Nov 2025 19:37:43 +0100	[thread overview]
Message-ID: <20251105183743.1800500-1-andriy.shevchenko@linux.intel.com> (raw)

In the snippets like the following

	if (...)
		return / goto / break / continue ...;
	else
		...

the 'else' is redundant. Get rid of it.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/nvdimm/label.c | 60 ++++++++++++++++++++----------------------
 1 file changed, 29 insertions(+), 31 deletions(-)

diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c
index 04f4a049599a..b129f3a55a70 100644
--- a/drivers/nvdimm/label.c
+++ b/drivers/nvdimm/label.c
@@ -734,13 +734,13 @@ static enum nvdimm_claim_class guid_to_nvdimm_cclass(guid_t *guid)
 {
 	if (guid_equal(guid, &nvdimm_btt_guid))
 		return NVDIMM_CCLASS_BTT;
-	else if (guid_equal(guid, &nvdimm_btt2_guid))
+	if (guid_equal(guid, &nvdimm_btt2_guid))
 		return NVDIMM_CCLASS_BTT2;
-	else if (guid_equal(guid, &nvdimm_pfn_guid))
+	if (guid_equal(guid, &nvdimm_pfn_guid))
 		return NVDIMM_CCLASS_PFN;
-	else if (guid_equal(guid, &nvdimm_dax_guid))
+	if (guid_equal(guid, &nvdimm_dax_guid))
 		return NVDIMM_CCLASS_DAX;
-	else if (guid_equal(guid, &guid_null))
+	if (guid_equal(guid, &guid_null))
 		return NVDIMM_CCLASS_NONE;
 
 	return NVDIMM_CCLASS_UNKNOWN;
@@ -751,13 +751,13 @@ static enum nvdimm_claim_class uuid_to_nvdimm_cclass(uuid_t *uuid)
 {
 	if (uuid_equal(uuid, &nvdimm_btt_uuid))
 		return NVDIMM_CCLASS_BTT;
-	else if (uuid_equal(uuid, &nvdimm_btt2_uuid))
+	if (uuid_equal(uuid, &nvdimm_btt2_uuid))
 		return NVDIMM_CCLASS_BTT2;
-	else if (uuid_equal(uuid, &nvdimm_pfn_uuid))
+	if (uuid_equal(uuid, &nvdimm_pfn_uuid))
 		return NVDIMM_CCLASS_PFN;
-	else if (uuid_equal(uuid, &nvdimm_dax_uuid))
+	if (uuid_equal(uuid, &nvdimm_dax_uuid))
 		return NVDIMM_CCLASS_DAX;
-	else if (uuid_equal(uuid, &uuid_null))
+	if (uuid_equal(uuid, &uuid_null))
 		return NVDIMM_CCLASS_NONE;
 
 	return NVDIMM_CCLASS_UNKNOWN;
@@ -768,20 +768,20 @@ static const guid_t *to_abstraction_guid(enum nvdimm_claim_class claim_class,
 {
 	if (claim_class == NVDIMM_CCLASS_BTT)
 		return &nvdimm_btt_guid;
-	else if (claim_class == NVDIMM_CCLASS_BTT2)
+	if (claim_class == NVDIMM_CCLASS_BTT2)
 		return &nvdimm_btt2_guid;
-	else if (claim_class == NVDIMM_CCLASS_PFN)
+	if (claim_class == NVDIMM_CCLASS_PFN)
 		return &nvdimm_pfn_guid;
-	else if (claim_class == NVDIMM_CCLASS_DAX)
+	if (claim_class == NVDIMM_CCLASS_DAX)
 		return &nvdimm_dax_guid;
-	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;
 }
 
 /* CXL labels store UUIDs instead of GUIDs for the same data */
@@ -790,20 +790,20 @@ static const uuid_t *to_abstraction_uuid(enum nvdimm_claim_class claim_class,
 {
 	if (claim_class == NVDIMM_CCLASS_BTT)
 		return &nvdimm_btt_uuid;
-	else if (claim_class == NVDIMM_CCLASS_BTT2)
+	if (claim_class == NVDIMM_CCLASS_BTT2)
 		return &nvdimm_btt2_uuid;
-	else if (claim_class == NVDIMM_CCLASS_PFN)
+	if (claim_class == NVDIMM_CCLASS_PFN)
 		return &nvdimm_pfn_uuid;
-	else if (claim_class == NVDIMM_CCLASS_DAX)
+	if (claim_class == NVDIMM_CCLASS_DAX)
 		return &nvdimm_dax_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;
 }
 
 static void reap_victim(struct nd_mapping *nd_mapping,
@@ -990,9 +990,7 @@ static int init_labels(struct nd_mapping *nd_mapping, int num_labels)
 		mutex_unlock(&nd_mapping->lock);
 	}
 
-	if (ndd->ns_current == -1 || ndd->ns_next == -1)
-		/* pass */;
-	else
+	if (ndd->ns_current != -1 && ndd->ns_next != -1)
 		return max(num_labels, old_num_labels);
 
 	nsindex = to_namespace_index(ndd, 0);
-- 
2.50.1


             reply	other threads:[~2025-11-05 18:37 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-05 18:37 Andy Shevchenko [this message]
2025-11-05 19:18 ` [PATCH v1 1/1] libnvdimm/labels: Get rid of redundant 'else' 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
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=20251105183743.1800500-1-andriy.shevchenko@linux.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