Skip to contentSkip to conversation

nvdimm: fix some compilation warnings

PATCH RESEND In review Qian Cai 3 participants 9 messages May 14, 2019 – Jun 26, 2019

Subsystems (2)
lore
Share & tools
lore

Qian Cai

author
#0 lore raw

PATCH RESEND 1/1 nvdimm: fix some compilation warnings

Several places (dimm_devs.c, core.c etc) include label.h but only label.c uses NSINDEX_SIGNATURE, so move its definition to label.c instead.
In file included from drivers/nvdimm/dimm_devs.c:23:
drivers/nvdimm/label.h:41:19: warning: 'NSINDEX_SIGNATURE' defined but not used [-Wunused-const-variable=]

The commit d9b83c756953 ("libnvdimm, btt: rework error clearing") left an unused variable.
drivers/nvdimm/btt.c: In function 'btt_read_pg':
drivers/nvdimm/btt.c:1272:8: warning: variable 'rc' set but not used [-Wunused-but-set-variable]

Last, some places abuse "/**" which is only reserved for the kernel-doc. drivers/nvdimm/bus.c:648: warning: cannot understand function prototype:
'struct attribute_group nd_device_attribute_group = ' drivers/nvdimm/bus.c:677: warning: cannot understand function prototype:
'struct attribute_group nd_numa_attribute_group = '

---
 drivers/nvdimm/btt.c   | 6 ++----
 drivers/nvdimm/bus.c   | 4 ++--
 drivers/nvdimm/label.c | 2 ++
 drivers/nvdimm/label.h | 2 --
 4 files changed, 6 insertions(+), 8 deletions(-)
drivers/nvdimm/btt.c +2 -4
index 4671776f5623..9f02a99cfac0 100644
@@ -1269,11 +1269,9 @@ static int btt_read_pg(struct btt *btt, struct bio_integrity_payload *bip,
 
 		ret = btt_data_read(arena, page, off, postmap, cur_len);
 		if (ret) {
-			int rc;
-
 			/* Media error - set the e_flag */
-			rc = btt_map_write(arena, premap, postmap, 0, 1,
-				NVDIMM_IO_ATOMIC);
+			btt_map_write(arena, premap, postmap, 0, 1,
+				      NVDIMM_IO_ATOMIC);
 			goto out_rtt;
 		}
 
drivers/nvdimm/bus.c +2 -2
index 7ff684159f29..2eb6a6cfe9e4 100644
@@ -642,7 +642,7 @@ static struct attribute *nd_device_attributes[] = {
 	NULL,
 };
 
-/**
+/*
  * nd_device_attribute_group - generic attributes for all devices on an nd bus
  */
 struct attribute_group nd_device_attribute_group = {
@@ -671,7 +671,7 @@ static umode_t nd_numa_attr_visible(struct kobject *kobj, struct attribute *a,
 	return a->mode;
 }
 
-/**
+/*
  * nd_numa_attribute_group - NUMA attributes for all devices on an nd bus
  */
 struct attribute_group nd_numa_attribute_group = {
drivers/nvdimm/label.c +2 -0
index f3d753d3169c..02a51b7775e1 100644
@@ -25,6 +25,8 @@ static guid_t nvdimm_btt2_guid;
 static guid_t nvdimm_pfn_guid;
 static guid_t nvdimm_dax_guid;
 
+static const char NSINDEX_SIGNATURE[] = "NAMESPACE_INDEX\0";
+
 static u32 best_seq(u32 a, u32 b)
 {
 	a &= NSINDEX_SEQ_MASK;
drivers/nvdimm/label.h +0 -2
index e9a2ad3c2150..4bb7add39580 100644
@@ -38,8 +38,6 @@ enum {
 	ND_NSINDEX_INIT = 0x1,
 };
 
-static const char NSINDEX_SIGNATURE[] = "NAMESPACE_INDEX\0";
-
 /**
  * struct nd_namespace_index - label set superblock
  * @sig: NAMESPACE_INDEX\0
Signature · 6 lines
2.20.1 (Apple Git-117)

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#1 lore raw
Quoted 14 lines · Qian Cai

Several places (dimm_devs.c, core.c etc) include label.h but only label.c uses NSINDEX_SIGNATURE, so move its definition to label.c instead.
In file included from drivers/nvdimm/dimm_devs.c:23:
drivers/nvdimm/label.h:41:19: warning: 'NSINDEX_SIGNATURE' defined but not used [-Wunused-const-variable=]

The commit d9b83c756953 ("libnvdimm, btt: rework error clearing") left an unused variable.
drivers/nvdimm/btt.c: In function 'btt_read_pg':
drivers/nvdimm/btt.c:1272:8: warning: variable 'rc' set but not used [-Wunused-but-set-variable]

Quoted 5 lines

Last, some places abuse "/**" which is only reserved for the kernel-doc. drivers/nvdimm/bus.c:648: warning: cannot understand function prototype:
'struct attribute_group nd_device_attribute_group = ' drivers/nvdimm/bus.c:677: warning: cannot understand function prototype:
'struct attribute_group nd_numa_attribute_group = '

Can you include the compiler where these errors start appearing, since I don't see these warnings with gcc-8.3.1

Quoted 16 lines
---
 drivers/nvdimm/btt.c   | 6 ++----
 drivers/nvdimm/bus.c   | 4 ++--
 drivers/nvdimm/label.c | 2 ++
 drivers/nvdimm/label.h | 2 --
 4 files changed, 6 insertions(+), 8 deletions(-)
drivers/nvdimm/btt.c +0 -0
index 4671776f5623..9f02a99cfac0 100644
@@ -1269,11 +1269,9 @@ static int btt_read_pg(struct btt *btt, struct bio_integrity_payload *bip,
 

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

Quoted 10 lines
drivers/nvdimm/btt.c +2 -4
                ret = btt_data_read(arena, page, off, postmap, cur_len);
                if (ret) {
-                       int rc;
-
                        /* Media error - set the e_flag */
-                       rc = btt_map_write(arena, premap, postmap, 0, 1,
-                               NVDIMM_IO_ATOMIC);
+                       btt_map_write(arena, premap, postmap, 0, 1,
+                                     NVDIMM_IO_ATOMIC);
                        goto out_rtt;

This doesn't look correct to me, shouldn't we at least be logging that the bad-block failed to be persistently tracked?

Quoted 16 lines
drivers/nvdimm/btt.c +0 -0
                }
 
drivers/nvdimm/bus.c +1 -1
index 7ff684159f29..2eb6a6cfe9e4 100644
@@ -642,7 +642,7 @@ static struct attribute *nd_device_attributes[] = {
        NULL,
 };
 
-/**
+/*
  * nd_device_attribute_group - generic attributes for all devices on an nd bus
  */
 struct attribute_group nd_device_attribute_group = {

drivers/nvdimm/bus.c static umode_t nd_numa_attr_visible(struct kobject *kobj, struct attribute *a, · line 676

Quoted 7 lines
drivers/nvdimm/bus.c +1 -1
@@ -671,7 +671,7 @@ static umode_t nd_numa_attr_visible(struct kobject *kobj, struct attribute *a,
        return a->mode;
 }
 
-/**
+/*
  * nd_numa_attribute_group - NUMA attributes for all devices on an nd bus
  */

Lets just fix this to be a valid kernel-doc format for a struct.

@@ -672,7 +672,7 @@ static umode_t nd_numa_attr_visible(struct kobject *kobj, struct attribute *a,
}

/**
- * nd_numa_attribute_group - NUMA attributes for all devices on an nd bus
+ * struct nd_numa_attribute_group - NUMA attributes for all devices on an nd bus
*/
struct attribute_group nd_numa_attribute_group = {
.attrs = nd_numa_attributes,

drivers/nvdimm/label.c static guid_t nvdimm_btt2_guid; · line 29

Quoted 11 lines
drivers/nvdimm/bus.c +0 -0
 struct attribute_group nd_numa_attribute_group = {
drivers/nvdimm/label.c +2 -0
index f3d753d3169c..02a51b7775e1 100644
@@ -25,6 +25,8 @@ static guid_t nvdimm_btt2_guid;
 static guid_t nvdimm_pfn_guid;
 static guid_t nvdimm_dax_guid;
 
+static const char NSINDEX_SIGNATURE[] = "NAMESPACE_INDEX\0";
+

Looks good to me.

Quoted 17 lines
drivers/nvdimm/label.c +0 -0
 static u32 best_seq(u32 a, u32 b)
 {
        a &= NSINDEX_SEQ_MASK;
drivers/nvdimm/label.h +0 -3
index e9a2ad3c2150..4bb7add39580 100644
@@ -38,8 +38,6 @@ enum {
        ND_NSINDEX_INIT = 0x1,
 };
 
-static const char NSINDEX_SIGNATURE[] = "NAMESPACE_INDEX\0";
-
 /**
  * struct nd_namespace_index - label set superblock
  * @sig: NAMESPACE_INDEX\0
--
Quoted 2 lines

2.20.1 (Apple Git-117)

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

maintainer
#2 lore raw
Quoted 7 lines · Dan Williams
Quoted 7 lines
drivers/nvdimm/btt.c +0 -0
index 4671776f5623..9f02a99cfac0 100644
@@ -1269,11 +1269,9 @@ static int btt_read_pg(struct btt *btt, struct bio_integrity_payload *bip,
 
Quoted 13 lines

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

Quoted 10 lines
drivers/nvdimm/btt.c +2 -4
                ret = btt_data_read(arena, page, off, postmap, cur_len);
                if (ret) {
-                       int rc;
-
                        /* Media error - set the e_flag */
-                       rc = btt_map_write(arena, premap, postmap, 0, 1,
-                               NVDIMM_IO_ATOMIC);
+                       btt_map_write(arena, premap, postmap, 0, 1,
+                                     NVDIMM_IO_ATOMIC);
                        goto out_rtt;

This doesn't look correct to me, shouldn't we at least be logging that the bad-block failed to be persistently tracked?

Yes logging it sounds good to me. Qian, can you include this in your respin or shall I send a fix for it separately (since we were always ignoring the failure here regardless of this patch)?

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#3 lore raw
Quoted 23 lines · Vishal L
Quoted 7 lines · Dan Williams
Quoted 7 lines
drivers/nvdimm/btt.c +0 -0
index 4671776f5623..9f02a99cfac0 100644
@@ -1269,11 +1269,9 @@ static int btt_read_pg(struct btt *btt, struct bio_integrity_payload *bip,
 
Quoted 13 lines

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

Quoted 10 lines
drivers/nvdimm/btt.c +2 -4
                ret = btt_data_read(arena, page, off, postmap, cur_len);
                if (ret) {
-                       int rc;
-
                        /* Media error - set the e_flag */
-                       rc = btt_map_write(arena, premap, postmap, 0, 1,
-                               NVDIMM_IO_ATOMIC);
+                       btt_map_write(arena, premap, postmap, 0, 1,
+                                     NVDIMM_IO_ATOMIC);
                        goto out_rtt;

This doesn't look correct to me, shouldn't we at least be logging that the bad-block failed to be persistently tracked?

Quoted 3 lines

Yes logging it sounds good to me. Qian, can you include this in your respin or shall I send a fix for it separately (since we were always ignoring the failure here regardless of this patch)?

I think a separate fix for this makes more sense. Likely also needs to be a ratelimited message in case a storm of errors is encountered.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

maintainer
#4 lore raw
Quoted 28 lines · Dan Williams
Quoted 26 lines · Vishal L
Quoted 24 lines · Dan Williams
Quoted 18 lines
drivers/nvdimm/btt.c +1 -4
index 4671776f5623..9f02a99cfac0 100644
@@ -1269,11 +1269,9 @@ static int btt_read_pg(struct btt *btt,
 struct bio_integrity_payload *bip,
 
                ret = btt_data_read(arena, page, off, postmap,
 cur_len);
                if (ret) {
-                       int rc;
-
                        /* Media error - set the e_flag */
-                       rc = btt_map_write(arena, premap,
 postmap, 0, 1,
-                               NVDIMM_IO_ATOMIC);
+                       btt_map_write(arena, premap, postmap, 0,

1,

Quoted 2 lines
+                                     NVDIMM_IO_ATOMIC);
                        goto out_rtt;

This doesn't look correct to me, shouldn't we at least be logging that
the bad-block failed to be persistently tracked?

Quoted 6 lines
Quoted 3 lines

Yes logging it sounds good to me. Qian, can you include this in your respin or shall I send a fix for it separately (since we were always ignoring the failure here regardless of this patch)?

I think a separate fix for this makes more sense. Likely also needs to be a ratelimited message in case a storm of errors is encountered.

Yes good point on rate limiting - I was thinking WARN_ONCE but that might mask errors for distinct blocks, but a rate limited printk should work best. I'll prepare a patch.

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

author
#5 lore raw
Quoted 33 lines · Vishal L
Quoted 32 lines · Dan Williams
Quoted 29 lines · Vishal L
Quoted 16 lines · Dan Williams
Quoted 16 lines
drivers/nvdimm/btt.c +0 -4
index 4671776f5623..9f02a99cfac0 100644
@@ -1269,11 +1269,9 @@ static int btt_read_pg(struct btt *btt,
 struct bio_integrity_payload *bip,
 
                 ret = btt_data_read(arena, page, off, postmap,
 cur_len);
                 if (ret) {
-                       int rc;
-
                         /* Media error - set the e_flag */
-                       rc = btt_map_write(arena, premap,
 postmap, 0, 1,
-                               NVDIMM_IO_ATOMIC);
Quoted 8 lines
Quoted 4 lines
drivers/nvdimm/btt.c +1 -0
+                       btt_map_write(arena, premap, postmap, 0,

1,
+                                     NVDIMM_IO_ATOMIC); goto out_rtt;

This doesn't look correct to me, shouldn't we at least be logging that
the bad-block failed to be persistently tracked?

Yes logging it sounds good to me. Qian, can you include this in your respin or shall I send a fix for it separately (since we were always ignoring the failure here regardless of this patch)?

Quoted 7 lines
Quoted 2 lines

I think a separate fix for this makes more sense. Likely also needs to be a ratelimited message in case a storm of errors is encountered.

Yes good point on rate limiting - I was thinking WARN_ONCE but that might mask errors for distinct blocks, but a rate limited printk should work best. I'll prepare a patch.

Verma, are you still working on this? I can still see this warning in the latest linux-next.

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

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

maintainer
#6 lore raw
Quoted 8 lines · Qian Cai

Verma, are you still working on this? I can still see this warning in the latest linux-next.

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

Sorry, this fell off the list. I'll take a look soon, but in the meanwhile, if a patch were to appear, I'd be happy to review it :) (i.e. feel free to take a shot at it).

Thanks,
-Vishal
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

author
#7 lore raw
In reply to Dan Williams
Quoted 34 lines
Quoted 17 lines
               }
drivers/nvdimm/bus.c +1 -1
index 7ff684159f29..2eb6a6cfe9e4 100644
@@ -642,7 +642,7 @@ static struct attribute *nd_device_attributes[] = {
       NULL,
 };
 
-/**
+/*
 * nd_device_attribute_group - generic attributes for all devices on an nd bus
 */
 struct attribute_group nd_device_attribute_group = {

drivers/nvdimm/bus.c static umode_t nd_numa_attr_visible(struct kobject *kobj, struct attribute *a, · line 676

Quoted 7 lines
drivers/nvdimm/bus.c +1 -1
@@ -671,7 +671,7 @@ static umode_t nd_numa_attr_visible(struct kobject *kobj, struct attribute *a,
       return a->mode;
 }
 
-/**
+/*
 * nd_numa_attribute_group - NUMA attributes for all devices on an nd bus
 */

Lets just fix this to be a valid kernel-doc format for a struct.

(quoted diff) +1 -1
@@ -672,7 +672,7 @@ static umode_t nd_numa_attr_visible(struct kobject
 *kobj, struct attribute *a,
 }
 
 /**
- * nd_numa_attribute_group - NUMA attributes for all devices on an nd bus
+ * struct nd_numa_attribute_group - NUMA attributes for all devices
Quoted 4 lines

on an nd bus
*/
struct attribute_group nd_numa_attribute_group = {
.attrs = nd_numa_attributes,

This won’t work because kernel-doc is to explain a struct definition, but this is a just an assignment. The "struct attribute_group” kernel-doc is in include/linux/sysfs.h.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

author
#8 lore raw
In reply to Dan Williams
Quoted 19 lines · Dan Williams
Quoted 14 lines · Qian Cai

Several places (dimm_devs.c, core.c etc) include label.h but only label.c uses NSINDEX_SIGNATURE, so move its definition to label.c instead.
In file included from drivers/nvdimm/dimm_devs.c:23:
drivers/nvdimm/label.h:41:19: warning: 'NSINDEX_SIGNATURE' defined but not used [-Wunused-const-variable=]

The commit d9b83c756953 ("libnvdimm, btt: rework error clearing") left an unused variable.
drivers/nvdimm/btt.c: In function 'btt_read_pg':
drivers/nvdimm/btt.c:1272:8: warning: variable 'rc' set but not used [-Wunused-but-set-variable]

Quoted 8 lines
Quoted 5 lines

Last, some places abuse "/**" which is only reserved for the kernel-doc. drivers/nvdimm/bus.c:648: warning: cannot understand function prototype:
'struct attribute_group nd_device_attribute_group = ' drivers/nvdimm/bus.c:677: warning: cannot understand function prototype:
'struct attribute_group nd_numa_attribute_group = '

Can you include the compiler where these errors start appearing, since I don't see these warnings with gcc-8.3.1

This can be reproduced by performing extra compiler checks, i.e, "make W=n”.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm