From: Joe Perches <joe@perches.com>
To: Dan Williams <dan.j.williams@intel.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Dave Jiang <dave.jiang@intel.com>,
Keith Busch <keith.busch@intel.com>,
Ira Weiny <ira.weiny@intel.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org
Subject: [PATCH 11/13] nvdimm: Use more common logic testing styles and bare ; positions
Date: Wed, 11 Sep 2019 19:54:41 -0700 [thread overview]
Message-ID: <d6aa5b66936f2e0f132e893e10494aae6b74e886.1568256708.git.joe@perches.com> (raw)
In-Reply-To: <cover.1568256705.git.joe@perches.com>
Avoid using uncommon logic testing styles to make the code a
bit more like other kernel code.
e.g.:
if (foo) {
;
} else {
<code>
}
is typically written
if (!foo) {
<code>
}
Also put bare semicolons before the comment not after the comment
e.g.:
if (foo) {
/* comment */;
} else if (bar) {
<code>
} else {
baz;
}
is typically written
if (foo) {
; /* comment */
} else if (bar) {
<code>
} else {
baz;
}
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/nvdimm/claim.c | 4 +---
drivers/nvdimm/dimm_devs.c | 11 ++++------
drivers/nvdimm/label.c | 4 +---
drivers/nvdimm/namespace_devs.c | 46 +++++++++++++++++++----------------------
drivers/nvdimm/region_devs.c | 4 +---
5 files changed, 28 insertions(+), 41 deletions(-)
diff --git a/drivers/nvdimm/claim.c b/drivers/nvdimm/claim.c
index 3732925aadb8..244631f5308c 100644
--- a/drivers/nvdimm/claim.c
+++ b/drivers/nvdimm/claim.c
@@ -149,9 +149,7 @@ ssize_t nd_namespace_store(struct device *dev,
return -ENOMEM;
strim(name);
- if (strncmp(name, "namespace", 9) == 0 || strcmp(name, "") == 0) {
- /* pass */;
- } else {
+ if (!(strncmp(name, "namespace", 9) == 0 || strcmp(name, "") == 0)) {
len = -EINVAL;
goto out;
}
diff --git a/drivers/nvdimm/dimm_devs.c b/drivers/nvdimm/dimm_devs.c
index 4df85dd72682..cac62bb726bb 100644
--- a/drivers/nvdimm/dimm_devs.c
+++ b/drivers/nvdimm/dimm_devs.c
@@ -593,13 +593,10 @@ int alias_dpa_busy(struct device *dev, void *data)
* looking to validate against PMEM aliasing collision rules
* (i.e. BLK is allocated after all aliased PMEM).
*/
- if (info->res) {
- if (info->res->start >= nd_mapping->start &&
- info->res->start < map_end)
- /* pass */;
- else
- return 0;
- }
+ if (info->res &&
+ (info->res->start < nd_mapping->start ||
+ info->res->start >= map_end))
+ return 0;
retry:
/*
diff --git a/drivers/nvdimm/label.c b/drivers/nvdimm/label.c
index e4632dbebead..ae466c6faa90 100644
--- a/drivers/nvdimm/label.c
+++ b/drivers/nvdimm/label.c
@@ -1180,9 +1180,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);
diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 8c75ef84bad7..7a16340f9853 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -162,7 +162,7 @@ unsigned int pmem_sector_size(struct nd_namespace_common *ndns)
nspm = to_nd_namespace_pmem(&ndns->dev);
if (nspm->lbasize == 0 || nspm->lbasize == 512)
- /* default */;
+ ; /* default */
else if (nspm->lbasize == 4096)
return 4096;
else
@@ -387,7 +387,7 @@ static int nd_namespace_label_update(struct nd_region *nd_region,
resource_size_t size = resource_size(&nspm->nsio.res);
if (size == 0 && nspm->uuid)
- /* delete allocation */;
+ ; /* delete allocation */
else if (!nspm->uuid)
return 0;
@@ -398,7 +398,7 @@ static int nd_namespace_label_update(struct nd_region *nd_region,
resource_size_t size = nd_namespace_blk_size(nsblk);
if (size == 0 && nsblk->uuid)
- /* delete allocation */;
+ ; /* delete allocation */
else if (!nsblk->uuid || !nsblk->lbasize)
return 0;
@@ -1900,10 +1900,8 @@ static int select_pmem_id(struct nd_region *nd_region, u8 *pmem_id)
hw_end = hw_start + nd_mapping->size;
pmem_start = __le64_to_cpu(nd_label->dpa);
pmem_end = pmem_start + __le64_to_cpu(nd_label->rawsize);
- if (pmem_start >= hw_start && pmem_start < hw_end &&
- pmem_end <= hw_end && pmem_end > hw_start) {
- /* pass */;
- } else {
+ if (!(pmem_start >= hw_start && pmem_start < hw_end &&
+ pmem_end <= hw_end && pmem_end > hw_start)) {
dev_dbg(&nd_region->dev, "%s invalid label for %pUb\n",
dev_name(ndd->dev), nd_label->uuid);
return -EINVAL;
@@ -2326,15 +2324,12 @@ static struct device **scan_labels(struct nd_region *nd_region)
list_for_each_entry_safe(label_ent, e, &nd_mapping->labels, list) {
struct nd_namespace_label *nd_label = label_ent->label;
struct device **__devs;
- u32 flags;
+ bool localflag;
if (!nd_label)
continue;
- flags = __le32_to_cpu(nd_label->flags);
- if (is_nd_blk(&nd_region->dev)
- == !!(flags & NSLABEL_FLAG_LOCAL))
- /* pass, region matches label type */;
- else
+ localflag = __le32_to_cpu(nd_label->flags) & NSLABEL_FLAG_LOCAL;
+ if (is_nd_blk(&nd_region->dev) != localflag)
continue;
/* skip labels that describe extents outside of the region */
@@ -2494,19 +2489,20 @@ static int init_active_labels(struct nd_region *nd_region)
* the region from being activated.
*/
if (!ndd) {
- if (test_bit(NDD_LOCKED, &nvdimm->flags))
- /* fail, label data may be unreadable */;
- else if (test_bit(NDD_ALIASING, &nvdimm->flags))
- /* fail, labels needed to disambiguate dpa */;
- else
- return 0;
-
- dev_err(&nd_region->dev, "%s: is %s, failing probe\n",
- dev_name(&nd_mapping->nvdimm->dev),
- test_bit(NDD_LOCKED, &nvdimm->flags)
- ? "locked" : "disabled");
- return -ENXIO;
+ if (test_bit(NDD_LOCKED, &nvdimm->flags) ||
+ /* label data may be unreadable */
+ test_bit(NDD_ALIASING, &nvdimm->flags)) {
+ /* labels needed to disambiguate dpa */
+
+ dev_err(&nd_region->dev, "%s: is %s, failing probe\n",
+ dev_name(&nd_mapping->nvdimm->dev),
+ test_bit(NDD_LOCKED, &nvdimm->flags)
+ ? "locked" : "disabled");
+ return -ENXIO;
+ }
+ return 0;
}
+
nd_mapping->ndd = ndd;
atomic_inc(&nvdimm->busy);
get_ndd(ndd);
diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
index 65df07481909..6861e0997d21 100644
--- a/drivers/nvdimm/region_devs.c
+++ b/drivers/nvdimm/region_devs.c
@@ -320,9 +320,7 @@ static ssize_t set_cookie_show(struct device *dev,
struct nd_interleave_set *nd_set = nd_region->nd_set;
ssize_t rc = 0;
- if (is_memory(dev) && nd_set)
- /* pass, should be precluded by region_visible */;
- else
+ if (!(is_memory(dev) && nd_set))
return -ENXIO;
/*
--
2.15.0
next prev parent reply other threads:[~2019-09-12 2:55 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-12 2:54 [PATCH 00/13] nvdimm: Use more common kernel coding style Joe Perches
2019-09-12 2:54 ` [PATCH 01/13] nvdimm: Use more typical whitespace Joe Perches
2019-09-12 12:17 ` Christoph Hellwig
2019-09-12 15:01 ` Joe Perches
2019-09-16 7:07 ` Christoph Hellwig
2019-09-12 2:54 ` [PATCH 02/13] nvdimm: Move logical continuations to previous line Joe Perches
2019-09-12 2:54 ` [PATCH 03/13] nvdimm: Use octal permissions Joe Perches
2019-09-12 2:54 ` [PATCH 04/13] nvdimm: Use a more common kernel spacing style Joe Perches
2019-09-12 2:54 ` [PATCH 05/13] nvdimm: Use "unsigned int" in preference to "unsigned" Joe Perches
2019-09-12 2:54 ` [PATCH 06/13] nvdimm: Add and remove blank lines Joe Perches
2019-09-12 2:54 ` [PATCH 07/13] nvdimm: Use typical kernel brace styles Joe Perches
2019-09-12 2:54 ` [PATCH 08/13] nvdimm: Use typical kernel style indentation Joe Perches
2019-09-12 2:54 ` [PATCH 09/13] nvdimm: btt.h: Neaten #defines to improve readability Joe Perches
2019-09-12 2:54 ` [PATCH 10/13] nvdimm: namespace_devs: Move assignment operators Joe Perches
2019-09-12 2:54 ` Joe Perches [this message]
2019-09-12 3:52 ` [PATCH 11/13] nvdimm: Use more common logic testing styles and bare ; positions Verma, Vishal L
2019-09-12 2:54 ` [PATCH 12/13] nvdimm: namespace_devs: Change progess typo to progress Joe Perches
2019-09-12 2:54 ` [PATCH 13/13] nvdimm: Miscellaneous neatening Joe Perches
2019-09-12 8:00 ` [PATCH 00/13] nvdimm: Use more common kernel coding style Dan Williams
2019-09-12 8:15 ` Joe Perches
2019-09-12 8:42 ` Miguel Ojeda
2019-09-12 14:00 ` Jeff Moyer
2019-09-12 14:06 ` Johannes Thumshirn
2019-09-12 14:35 ` Dan Williams
2019-09-12 14:21 ` Miguel Ojeda
2019-09-12 21:08 ` Joe Perches
2019-09-12 21:58 ` Miguel Ojeda
2019-09-12 22:15 ` Joe Perches
2019-09-12 22:38 ` Joe Perches
2019-09-12 23:00 ` Nick Desaulniers
2019-09-12 23:07 ` Joe Perches
2019-09-12 22:58 ` Nick Desaulniers
2019-09-12 23:26 ` clang-format and 'clang-format on' and 'clang-format off' Joe Perches
2019-09-15 18:25 ` Miguel Ojeda
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=d6aa5b66936f2e0f132e893e10494aae6b74e886.1568256708.git.joe@perches.com \
--to=joe@perches.com \
--cc=dan.carpenter@oracle.com \
--cc=dan.j.williams@intel.com \
--cc=dave.jiang@intel.com \
--cc=ira.weiny@intel.com \
--cc=keith.busch@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvdimm@lists.01.org \
--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;
as well as URLs for NNTP newsgroup(s).