Skip to contentSkip to conversation

nvdimm/btt: fix variable 'rc' set but not used

PATCH Superseded Qian Cai 2 participants 3 messages Oct 30, 2019

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Qian Cai

author
#0 lore raw

PATCH v2 1/1 nvdimm/btt: fix variable 'rc' set but not used

drivers/nvdimm/btt.c: In function 'btt_read_pg':
drivers/nvdimm/btt.c:1264:8: warning: variable 'rc' set but not used [-Wunused-but-set-variable]

    int rc;
        ^~

Add a ratelimited message in case a storm of errors is encountered.

Fixes d9b83c756953 ("libnvdimm, btt: rework error clearing")

---

v2: include the block address that is returning an error per Dan.

 drivers/nvdimm/btt.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/nvdimm/btt.c +6 -0
index 3e9f45aec8d1..10313be78221 100644
@@ -1266,6 +1266,12 @@ static int btt_read_pg(struct btt *btt, struct bio_integrity_payload *bip,
 			/* Media error - set the e_flag */
 			rc = btt_map_write(arena, premap, postmap, 0, 1,
 				NVDIMM_IO_ATOMIC);
+
+			if (rc)
+				dev_warn_ratelimited(to_dev(arena),
+					"Error persistently tracking bad blocks at %#x\n",
+					premap);
+
 			goto out_rtt;
 		}
 
Signature · 4 lines
1.8.3.1
_______________________________________________
Linux-nvdimm mailing list -- [email protected]
To unsubscribe send an email to [email protected]
maintainer
#1 lore raw
Quoted 23 lines · Qian Cai

drivers/nvdimm/btt.c: In function 'btt_read_pg':
drivers/nvdimm/btt.c:1264:8: warning: variable 'rc' set but not used [-Wunused-but-set-variable]

    int rc;
        ^~

Add a ratelimited message in case a storm of errors is encountered.

Fixes d9b83c756953 ("libnvdimm, btt: rework error clearing")

---

v2: include the block address that is returning an error per Dan.

 drivers/nvdimm/btt.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/nvdimm/btt.c +0 -0
index 3e9f45aec8d1..10313be78221 100644
@@ -1266,6 +1266,12 @@ static int btt_read_pg(struct btt *btt, struct bio_integrity_payload *bip,
 			/* Media error - set the e_flag */

drivers/nvdimm/btt.c static int btt_read_pg(struct btt *btt, struct bio_integrity_payload *bip, · line 1276

Quoted 10 lines
drivers/nvdimm/btt.c +6 -0
 			rc = btt_map_write(arena, premap, postmap, 0, 1,
 				NVDIMM_IO_ATOMIC);
+
+			if (rc)
+				dev_warn_ratelimited(to_dev(arena),
+					"Error persistently tracking bad blocks at %#x\n",
+					premap);
+
 			goto out_rtt;
 		}

Good find! Since we're not really using rc later, we should just simplify this to:

	if (btt_map_write(...))
		dev_warn_ratelimited(...)
	goto out_rtt;
author
#2 lore raw
Quoted 10 lines · Vishal L

Good find! Since we're not really using rc later, we should just simplify this to:

   if (btt_map_write(...))
       dev_warn_ratelimited(...)
   goto out_rtt;

Ah, I thought about printing the rc as well at first, but it seems only return -EIO for errors, so I agree with you.