hw/block: nvme: Fix a build error in nvme_get_feature()
PATCH v2 1/1 hw/block: nvme: Fix a build error in nvme_get_feature()
From: Bin Meng <[email protected]>
Current QEMU HEAD nvme.c does not compile:
hw/block/nvme.c:3242:9: error: ‘result’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
trace_pci_nvme_getfeat_vwcache(result ? "enabled" : "disabled");
^
hw/block/nvme.c:3150:14: note: ‘result’ was declared here
uint32_t result;
^Explicitly initialize the result to fix it.
---
Changes in v2:
- update function name in the commit message
hw/block/nvme.c | 1 + 1 file changed, 1 insertion(+)
hw/block/nvme.c +1 -0
@@ -3228,6 +3228,7 @@ static uint16_t nvme_get_feature(NvmeCtrl *n, NvmeRequest *req) result = ns->features.err_rec; goto out;case NVME_VOLATILE_WRITE_CACHE : + result =0 ;for (i =1 ; i <= n->num_namespaces; i++) { ns =nvme_ns (n, i);if (!ns) {
Signature · 1 line
2.7.4
CC qemu-trivial.
Quoted 40 lines · Bin Meng
From: Bin Meng <[email protected]>
Current QEMU HEAD
nvme.cdoes not compile:
hw/block/nvme.c:3242:9: error: ‘result’ may be used uninitialized in this function [-Werror=maybe-uninitialized]trace_pci_nvme_getfeat_vwcache(result ? "enabled" : "disabled"); ^ hw/block/nvme.c:3150:14: note: ‘result’ was declared here uint32_t result; ^Explicitly initialize the result to fix it.
Fixes aa5e55e3b07e ("hw/block/nvme: open code for volatile write cache")Signed-off-by Bin Meng <[email protected]>---
Changes in v2:
- update function name in the commit messagehw/block/nvme.c | 1 + 1 file changed, 1 insertion(+)hw/block/nvme.c +1
-0@@ -3228,6 +3228,7 @@ static uint16_t nvme_get_feature(NvmeCtrl *n, NvmeRequest *req) result = ns->features.err_rec; goto out;case NVME_VOLATILE_WRITE_CACHE : + result =0 ;for (i =1 ; i <= n->num_namespaces; i++) { ns =nvme_ns (n, i);if (!ns) {Signature · 1 line
2.7.4
Quoted 11 lines · Bin Meng
From: Bin Meng <[email protected]>
Current QEMU HEAD
nvme.cdoes not compile:
hw/block/nvme.c:3242:9: error: ‘result’ may be used uninitialized in this function [-Werror=maybe-uninitialized]trace_pci_nvme_getfeat_vwcache(result ? "enabled" : "disabled"); ^ hw/block/nvme.c:3150:14: note: ‘result’ was declared here uint32_t result; ^
Quoted 4 lines
Explicitly initialize the result to fix it.
Fixes aa5e55e3b07e ("hw/block/nvme: open code for volatile write cache")Signed-off-by Bin Meng <[email protected]>
Bin,
Thanks for the fix!
Hi Bin,
Quoted 10 lines · Bin Meng
From: Bin Meng <[email protected]>
Current QEMU HEAD
nvme.cdoes not compile:
hw/block/nvme.c:3242:9: error: ‘result’ may be used uninitialized in this function [-Werror=maybe-uninitialized]trace_pci_nvme_getfeat_vwcache(result ? "enabled" : "disabled"); ^ hw/block/nvme.c:3150:14: note: ‘result’ was declared here uint32_t result; ^
Why isn't this catched by our CI? What is your host OS? Fedora 33?
Quoted 13 lines
Explicitly initialize the result to fix it.
Fixes aa5e55e3b07e ("hw/block/nvme: open code for volatile write cache")Signed-off-by Bin Meng <[email protected]>---
Changes in v2:
- update function name in the commit messagehw/block/nvme.c | 1 + 1 file changed, 1 insertion(+)
Hi Philippe,
Quoted 8 lines · Philippe Mathieu-Daudé
Hi Bin,
Quoted 4 lines · Bin Meng
From: Bin Meng <[email protected]>
Current QEMU HEAD
nvme.cdoes not compile:
Quoted 9 lines
Quoted 6 lines
hw/block/nvme.c:3242:9: error: ‘result’ may be used uninitialized in this function [-Werror=maybe-uninitialized]trace_pci_nvme_getfeat_vwcache(result ? "enabled" : "disabled"); ^ hw/block/nvme.c:3150:14: note: ‘result’ was declared here uint32_t result; ^Why isn't this catched by our CI? What is your host OS? Fedora 33?
I am using GCC 5.4 on Ubuntu 16.04. Please see some initial analysis from Peter about why newer version GCC does not report it.
Regards,
Bin
Quoted 19 lines · Bin Meng
Hi Philippe,
Quoted 15 lines · Philippe Mathieu-Daudé
Hi Bin,
Quoted 10 lines · Bin Meng
From: Bin Meng <[email protected]>
Current QEMU HEAD
nvme.cdoes not compile:hw/block/nvme.c:3242:9: error: ‘result’ may be used uninitialized in this function [-Werror=maybe-uninitialized] trace_pci_nvme_getfeat_vwcache(result ? "enabled" : "disabled"); ^ hw/block/nvme.c:3150:14: note: ‘result’ was declared here uint32_t result; ^
Quoted 5 lines
Quoted 2 lines
Why isn't this catched by our CI? What is your host OS? Fedora 33?
I am using GCC 5.4 on Ubuntu 16.04. Please see some initial analysis from Peter about why newer version GCC does not report it.
Please note that Ubuntu 16.04 is not a supported version by QEMU anymore, see https://qemu.readthedocs.io/en/latest/system/build-platforms.html and https://wiki.qemu.org/Supported_Build_Platforms for details.
Thomas
Quoted 7 lines · Philippe Mathieu-Daudé
Hi Bin,
Quoted 4 lines · Bin Meng
From: Bin Meng <[email protected]>
Current QEMU HEAD
nvme.cdoes not compile:
Quoted 8 lines
Quoted 6 lines
hw/block/nvme.c:3242:9: error: ‘result’ may be used uninitialized in this function [-Werror=maybe-uninitialized]trace_pci_nvme_getfeat_vwcache(result ? "enabled" : "disabled"); ^ hw/block/nvme.c:3150:14: note: ‘result’ was declared here uint32_t result; ^Why isn't this catched by our CI? What is your host OS? Fedora 33?
Just noticed v1 and Peter's explanation:
https://lists.gnu.org/archive/html/qemu-devel/2021-02/msg03528.html
Can you amend "default GCC 5.4 on a Ubuntu 16.04 host" information please?
Quoted 14 lines
Quoted 14 lines
Explicitly initialize the result to fix it.
Fixes aa5e55e3b07e ("hw/block/nvme: open code for volatile write cache")Signed-off-by Bin Meng <[email protected]>---
Changes in v2:
- update function name in the commit messagehw/block/nvme.c | 1 + 1 file changed, 1 insertion(+)
Hi Philippe,
Quoted 16 lines · Philippe Mathieu-Daudé
Quoted 14 lines · Philippe Mathieu-Daudé
Hi Bin,
Quoted 10 lines · Bin Meng
From: Bin Meng <[email protected]>
Current QEMU HEAD
nvme.cdoes not compile:
hw/block/nvme.c:3242:9: error: ‘result’ may be used uninitialized in this function [-Werror=maybe-uninitialized]trace_pci_nvme_getfeat_vwcache(result ? "enabled" : "disabled"); ^ hw/block/nvme.c:3150:14: note: ‘result’ was declared here uint32_t result; ^
Quoted 8 lines
Quoted 1 line
Why isn't this catched by our CI? What is your host OS? Fedora 33?
Just noticed v1 and Peter's explanation:
https://lists.gnu.org/archive/html/qemu-devel/2021-02/msg03528.htmlCan you amend "default GCC 5.4 on a Ubuntu 16.04 host" information please?
Sure.
Regards,
Bin
Quoted 15 lines · Philippe Mathieu-Daudé
Quoted 14 lines · Philippe Mathieu-Daudé
Hi Bin,
Quoted 10 lines · Bin Meng
From: Bin Meng <[email protected]>
Current QEMU HEAD
nvme.cdoes not compile:
hw/block/nvme.c:3242:9: error: ‘result’ may be used uninitialized in this function [-Werror=maybe-uninitialized]trace_pci_nvme_getfeat_vwcache(result ? "enabled" : "disabled"); ^ hw/block/nvme.c:3150:14: note: ‘result’ was declared here uint32_t result; ^
Quoted 7 lines
Quoted 1 line
Why isn't this catched by our CI? What is your host OS? Fedora 33?
Just noticed v1 and Peter's explanation:
https://lists.gnu.org/archive/html/qemu-devel/2021-02/msg03528.htmlCan you amend "default GCC 5.4 on a Ubuntu 16.04 host" information please?
Well Ubuntu 16.04 hasn't been considered a supported build target for QEMU for a year now.
"The project aims to support the most recent major version
at all times. Support for the previous major version will be dropped 2 years after the new major version is released or when the vendor itself drops support, whichever comes first."
IOW, we only aim for QEMU to be buildable on Ubuntu LTS 20.04 and 18.04 at this point in time. 16.04 is explicitly dropped and we will increasingly introduce incompatibilities with it.
While this specific patch is simple, trying to keep QEMU git master working on 16.04 is not a goal, so I'd really suggest upgrading to a newer Ubuntu version at the soonest opportunity.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 35 lines · Daniel P. Berrangé
Quoted 15 lines · Philippe Mathieu-Daudé
Quoted 14 lines · Philippe Mathieu-Daudé
Hi Bin,
Quoted 10 lines · Bin Meng
From: Bin Meng <[email protected]>
Current QEMU HEAD
nvme.cdoes not compile:
hw/block/nvme.c:3242:9: error: ‘result’ may be used uninitialized in this function [-Werror=maybe-uninitialized]trace_pci_nvme_getfeat_vwcache(result ? "enabled" : "disabled"); ^ hw/block/nvme.c:3150:14: note: ‘result’ was declared here uint32_t result; ^Quoted 7 lines
Quoted 1 line
Why isn't this catched by our CI? What is your host OS? Fedora 33?
Just noticed v1 and Peter's explanation:
https://lists.gnu.org/archive/html/qemu-devel/2021-02/msg03528.htmlCan you amend "default GCC 5.4 on a Ubuntu 16.04 host" information please?
Well Ubuntu 16.04 hasn't been considered a supported build target for QEMU for a year now.
"The project aims to support the most recent major version
at all times. Support for the previous major version will be dropped 2 years after the new major version is released or when the vendor itself drops support, whichever comes first."
Quoted 7 lines
IOW, we only aim for QEMU to be buildable on Ubuntu LTS 20.04 and 18.04 at this point in time. 16.04 is explicitly dropped and we will increasingly introduce incompatibilities with it.
While this specific patch is simple, trying to keep QEMU git master working on 16.04 is not a goal, so I'd really suggest upgrading to a newer Ubuntu version at the soonest opportunity.
In particular after 6.0 QEMU is released, we'll be dropping RHEL-7 and then likely setting the min required GCC to somewhere around 6.3 which will cut off Ubuntu 16.04 upfront.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Quoted 30 lines · Bin Meng
From: Bin Meng <[email protected]>
Current QEMU HEAD
nvme.cdoes not compile:
hw/block/nvme.c:3242:9: error: ‘result’ may be used uninitialized in this function [-Werror=maybe-uninitialized]trace_pci_nvme_getfeat_vwcache(result ? "enabled" : "disabled"); ^ hw/block/nvme.c:3150:14: note: ‘result’ was declared here uint32_t result; ^Explicitly initialize the result to fix it.
Fixes aa5e55e3b07e ("hw/block/nvme: open code for volatile write cache")Signed-off-by Bin Meng <[email protected]>---
Changes in v2:
- update function name in the commit messagehw/block/nvme.c | 1 + 1 file changed, 1 insertion(+)hw/block/nvme.c +0
-0
hw/block/nvme.c static uint16_t nvme_get_feature(NvmeCtrl *n, NvmeRequest *req)
Quoted 8 lines
hw/block/nvme.c +1
-1@@ -3228,6 +3228,7 @@ static uint16_t nvme_get_feature(NvmeCtrl *n, NvmeRequest *req) result = ns->features.err_rec; goto out;case NVME_VOLATILE_WRITE_CACHE : + result =0 ;for (i =1 ; i <= n->num_namespaces; i++) { ns =nvme_ns (n, i);if (!ns) { --
Also spotted by Coverity: CID 1446371
-- PMM