Skip to contentSkip to conversation

dev/dax: fix uninitialized variable build warning

PATCH Superseded Ross Zwisler 2 participants 6 messages Oct 18, 2017 – Oct 20, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 dev/dax: fix uninitialized variable build warning

Fix this build warning:

warning: 'phys' may be used uninitialized in this function [-Wuninitialized]

As reported here:

https://lkml.org/lkml/2017/10/16/152

This should have no functional change because you can only get into the if statement in dax_pgoff_to_phys() that is complaining about 'phys' being uninitialized if you broke out early in the above loop, in which case 'phys' will be set.

---
 drivers/dax/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dax/device.c +1 -1
index e9f3b3e..4aca0a2 100644
@@ -222,7 +222,7 @@ __weak phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff,
 		unsigned long size)
 {
 	struct resource *res;
-	phys_addr_t phys;
+	phys_addr_t phys = 0;
 	int i;
 
 	for (i = 0; i < dev_dax->num_resources; i++) {
Signature · 6 lines
2.9.5

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

PATCH 2/2 MAINTAINERS: Add entry for device DAX

And update the entry for filesystem DAX to differentiate them.

---
 MAINTAINERS | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
MAINTAINERS +7 -1
index a74227a..b2b2e75 100644
@@ -4162,7 +4162,7 @@ L:	[email protected]
 S:	Maintained
 F:	drivers/i2c/busses/i2c-diolan-u2c.c
 
-DIRECT ACCESS (DAX)
+FILESYSTEM DIRECT ACCESS (DAX)
 M:	Matthew Wilcox <[email protected]>
 M:	Ross Zwisler <[email protected]>
 L:	[email protected]
@@ -4171,6 +4171,12 @@ F:	fs/dax.c
 F:	include/linux/dax.h
 F:	include/trace/events/fs_dax.h
 
+DEVICE DIRECT ACCESS (DAX)
+M:	Dan Williams <[email protected]>
+L:	[email protected]
+S:	Supported
+F:	drivers/dax/
+
 DIRECTORY NOTIFICATION (DNOTIFY)
 M:	Jan Kara <[email protected]>
 R:	Amir Goldstein <[email protected]>
Signature · 6 lines
2.9.5

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

Re: [PATCH 2/2] MAINTAINERS: Add entry for device DAX

Quoted 21 lines · Ross Zwisler

And update the entry for filesystem DAX to differentiate them.

---
 MAINTAINERS | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
MAINTAINERS +1 -1
index a74227a..b2b2e75 100644
@@ -4162,7 +4162,7 @@ L:        [email protected]
 S:     Maintained
 F:     drivers/i2c/busses/i2c-diolan-u2c.c
 
-DIRECT ACCESS (DAX)
+FILESYSTEM DIRECT ACCESS (DAX)
 M:     Matthew Wilcox <[email protected]>
 M:     Ross Zwisler <[email protected]>
 L:     [email protected]

MAINTAINERS F: fs/dax.c · line 4179

Quoted 9 lines
MAINTAINERS +6 -0
@@ -4171,6 +4171,12 @@ F:       fs/dax.c
 F:     include/linux/dax.h
 F:     include/trace/events/fs_dax.h
 
+DEVICE DIRECT ACCESS (DAX)
+M:     Dan Williams <[email protected]>
+L:     [email protected]
+S:     Supported
+F:     drivers/dax/
+

I guess I had a good run hiding from get_maintainers.pl...

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

#3 lore raw
In reply to Ross Zwisler
Quoted 5 lines · Ross Zwisler

Fix this build warning:

warning: 'phys' may be used uninitialized in this function [-Wuninitialized]

Quoted 8 lines

As reported here:

https://lkml.org/lkml/2017/10/16/152

This should have no functional change because you can only get into the if statement in dax_pgoff_to_phys() that is complaining about 'phys' being uninitialized if you broke out early in the above loop, in which case 'phys' will be set.

Then the compiler is wrong.

Quoted 11 lines
---
 drivers/dax/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dax/device.c +0 -0
index e9f3b3e..4aca0a2 100644

drivers/dax/device.c __weak phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff, · line 225

Quoted 5 lines
drivers/dax/device.c +1 -1
@@ -222,7 +222,7 @@ __weak phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff,
                unsigned long size)
 {
        struct resource *res;
-       phys_addr_t phys;
+       phys_addr_t phys = 0;

We have uninitialized_var() for silencing the compiler, and since the report is bogus we might note with a comment which gcc had a problem with this routine.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#4 lore raw

PATCH v2 1/1 dev/dax: fix uninitialized variable build warning

Fix this build warning:

warning: 'phys' may be used uninitialized in this function [-Wuninitialized]

As reported here:

https://lkml.org/lkml/2017/10/16/152
http://kisskb.ellerman.id.au/kisskb/buildresult/13181373/log/

---
 drivers/dax/device.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/dax/device.c +2 -1
index e9f3b3e..6833ada 100644
@@ -222,7 +222,8 @@ __weak phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff,
 		unsigned long size)
 {
 	struct resource *res;
-	phys_addr_t phys;
+	/* gcc-4.6.3-nolibc for i386 complains that this is uninitialized */
+	phys_addr_t uninitialized_var(phys);
 	int i;
 
 	for (i = 0; i < dev_dax->num_resources; i++) {
Signature · 6 lines
2.9.5

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#5 lore raw
Quoted 20 lines · Ross Zwisler

Fix this build warning:

warning: 'phys' may be used uninitialized in this function [-Wuninitialized]

As reported here:

https://lkml.org/lkml/2017/10/16/152
http://kisskb.ellerman.id.au/kisskb/buildresult/13181373/log/

---
 drivers/dax/device.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/dax/device.c +0 -0
index e9f3b3e..6833ada 100644

drivers/dax/device.c __weak phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff, · line 226

Quoted 6 lines
drivers/dax/device.c +2 -1
@@ -222,7 +222,8 @@ __weak phys_addr_t dax_pgoff_to_phys(struct dev_dax *dev_dax, pgoff_t pgoff,
                unsigned long size)
 {
        struct resource *res;
-       phys_addr_t phys;
+       /* gcc-4.6.3-nolibc for i386 complains that this is uninitialized */
+       phys_addr_t uninitialized_var(phys);

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