qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] hw/block: nvme: Fix a build error in nvme_get_feature()
@ 2021-02-10 11:22 Bin Meng
  2021-02-10 20:51 ` Klaus Jensen
  0 siblings, 1 reply; 2+ messages in thread
From: Bin Meng @ 2021-02-10 11:22 UTC (permalink / raw)
  To: Keith Busch, Kevin Wolf, Klaus Jensen, Max Reitz, qemu-block,
	qemu-devel
  Cc: qemu-trivial, Peter Maydell, Bin Meng, Minwoo Im

From: Bin Meng <bin.meng@windriver.com>

Current QEMU HEAD nvme.c does not compile with the default GCC 5.4
on a Ubuntu 16.04 host:

  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.

Cc: qemu-trivial@nongnu.org
Fixes: aa5e55e3b07e ("hw/block/nvme: open code for volatile write cache")
Signed-off-by: Bin Meng <bin.meng@windriver.com>

---

Changes in v3:
- mention compiler and host information in the commit message

Changes in v2:
- update function name in the commit message

 hw/block/nvme.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index 5ce21b7..c122ac0 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -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) {
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] hw/block: nvme: Fix a build error in nvme_get_feature()
  2021-02-10 11:22 [PATCH v3] hw/block: nvme: Fix a build error in nvme_get_feature() Bin Meng
@ 2021-02-10 20:51 ` Klaus Jensen
  0 siblings, 0 replies; 2+ messages in thread
From: Klaus Jensen @ 2021-02-10 20:51 UTC (permalink / raw)
  To: Bin Meng
  Cc: Kevin Wolf, Peter Maydell, qemu-block, qemu-trivial, Bin Meng,
	qemu-devel, Max Reitz, Minwoo Im, Keith Busch

[-- Attachment #1: Type: text/plain, Size: 1501 bytes --]

On Feb 10 19:22, Bin Meng wrote:
> From: Bin Meng <bin.meng@windriver.com>
> 
> Current QEMU HEAD nvme.c does not compile with the default GCC 5.4
> on a Ubuntu 16.04 host:
> 
>   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.
> 
> Cc: qemu-trivial@nongnu.org
> Fixes: aa5e55e3b07e ("hw/block/nvme: open code for volatile write cache")
> Signed-off-by: Bin Meng <bin.meng@windriver.com>
> 

Reviewed-by: Klaus Jensen <k.jensen@samsung.com>

> ---
> 
> Changes in v3:
> - mention compiler and host information in the commit message
> 
> Changes in v2:
> - update function name in the commit message
> 
>  hw/block/nvme.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
> index 5ce21b7..c122ac0 100644
> --- a/hw/block/nvme.c
> +++ b/hw/block/nvme.c
> @@ -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) {
> -- 
> 2.7.4
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-02-10 20:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-10 11:22 [PATCH v3] hw/block: nvme: Fix a build error in nvme_get_feature() Bin Meng
2021-02-10 20:51 ` Klaus Jensen

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).