diff options
author | Gollu Appalanaidu <anaidu.gollu@samsung.com> | 2021-02-22 19:36:09 +0100 |
---|---|---|
committer | Klaus Jensen <k.jensen@samsung.com> | 2021-03-09 11:00:57 +0100 |
commit | f4f872b532a53da7bc734cdb7cb166ec22d617d1 (patch) | |
tree | 37186cbffc156820eca89f6a94012d8f8d6736ea /hw/block/nvme.c | |
parent | 49f0eba8b2bdc0c9aeaac620b978da7cb0fa947f (diff) | |
download | qemu-f4f872b532a53da7bc734cdb7cb166ec22d617d1.zip qemu-f4f872b532a53da7bc734cdb7cb166ec22d617d1.tar.gz qemu-f4f872b532a53da7bc734cdb7cb166ec22d617d1.tar.bz2 |
hw/block/nvme: fix potential compilation error
assert may be compiled to a noop and we could end up returning an
uninitialized status.
Fix this by always returning Internal Device Error as a fallback.
Note that, as pointed out by Philippe, per commit 262a69f4282 ("osdep.h:
Prohibit disabling assert() in supported builds") this shouldn't be
possible. But clean it up so we don't worry about it again.
Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
[k.jensen: split commit]
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Diffstat (limited to 'hw/block/nvme.c')
-rw-r--r-- | hw/block/nvme.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/hw/block/nvme.c b/hw/block/nvme.c index f5538fd..de3d0ca 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -1246,8 +1246,6 @@ static uint16_t nvme_check_zone_write(NvmeNamespace *ns, NvmeZone *zone, static uint16_t nvme_check_zone_state_for_read(NvmeZone *zone) { - uint16_t status; - switch (nvme_get_zone_state(zone)) { case NVME_ZONE_STATE_EMPTY: case NVME_ZONE_STATE_IMPLICITLY_OPEN: @@ -1255,16 +1253,14 @@ static uint16_t nvme_check_zone_state_for_read(NvmeZone *zone) case NVME_ZONE_STATE_FULL: case NVME_ZONE_STATE_CLOSED: case NVME_ZONE_STATE_READ_ONLY: - status = NVME_SUCCESS; - break; + return NVME_SUCCESS; case NVME_ZONE_STATE_OFFLINE: - status = NVME_ZONE_OFFLINE; - break; + return NVME_ZONE_OFFLINE; default: assert(false); } - return status; + return NVME_INTERNAL_DEV_ERROR; } static uint16_t nvme_check_zone_read(NvmeNamespace *ns, uint64_t slba, |