From: Philippe Mathieu-Daudé Date: Mon, 16 Oct 2023 15:00:53 +0000 (+0200) Subject: hw/virtio/virtio-pmem: Replace impossible check by assertion X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=5960f254dbb46f0c7a9f5f44bf4d27c19c34cb97;p=qemu.git hw/virtio/virtio-pmem: Replace impossible check by assertion The get_memory_region() handler is used when (un)plugging the device, which can only occur *after* it is realized. virtio_pmem_realize() ensure the instance can not be realized without 'memdev'. Remove the superfluous check, replacing it by an assertion. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin Reviewed-by: Manos Pitsidianakis Message-Id: <20231017140150.44995-2-philmd@linaro.org> --- diff --git a/hw/virtio/virtio-pmem.c b/hw/virtio/virtio-pmem.c index c3512c2dae..cc24812d2e 100644 --- a/hw/virtio/virtio-pmem.c +++ b/hw/virtio/virtio-pmem.c @@ -147,10 +147,7 @@ static void virtio_pmem_fill_device_info(const VirtIOPMEM *pmem, static MemoryRegion *virtio_pmem_get_memory_region(VirtIOPMEM *pmem, Error **errp) { - if (!pmem->memdev) { - error_setg(errp, "'%s' property must be set", VIRTIO_PMEM_MEMDEV_PROP); - return NULL; - } + assert(pmem->memdev); return &pmem->memdev->mr; }