From patchwork Thu Mar 4 15:56:28 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [07/50] block: Simplify usb_msd_initfn() test for "can read bdrv key" From: Markus Armbruster X-Patchwork-Id: 46934 Message-Id: <1267718231-13303-8-git-send-email-armbru@redhat.com> To: qemu-devel@nongnu.org Cc: Luiz Capitulino Date: Thu, 4 Mar 2010 16:56:28 +0100 The old test assumes that "hotplugged" implies "we have a current monitor for reading the key". This is in fact true, but it's not obviously true. Aside: if it were false, we could pass a null pointer to monitor_read_bdrv_key_start(), which would then crash. The previous commit permits us to check for "we have a current monitor" directly, so do that. Signed-off-by: Markus Armbruster --- hw/usb-msd.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/hw/usb-msd.c b/hw/usb-msd.c index 1a11bc5..0afb031 100644 --- a/hw/usb-msd.c +++ b/hw/usb-msd.c @@ -535,7 +535,7 @@ static int usb_msd_initfn(USBDevice *dev) usb_msd_handle_reset(dev); if (bdrv_key_required(s->conf.dinfo->bdrv)) { - if (s->dev.qdev.hotplugged) { + if (cur_mon) { monitor_read_bdrv_key_start(cur_mon, s->conf.dinfo->bdrv, usb_msd_password_cb, s); s->dev.auto_attach = 0;