From 05cdd648a846bd60e300fcfa1eabf8f20e589cba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Thu, 16 Jan 2025 16:02:38 +0000 Subject: [PATCH] system: squash usb_parse into a single function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't need to wrap usb_device_add as usb_parse is already gated with an if (machine_usb(current_machine)) check. Instead just assert and directly fail if usbdevice_create returns NULL. Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Alex Bennée Message-Id: <20250116160306.1709518-10-alex.bennee@linaro.org> --- system/vl.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/system/vl.c b/system/vl.c index 22c1444da4..02795c5135 100644 --- a/system/vl.c +++ b/system/vl.c @@ -811,29 +811,15 @@ static void configure_msg(QemuOpts *opts) /***********************************************************/ /* USB devices */ -static int usb_device_add(const char *devname) -{ - USBDevice *dev = NULL; - - if (!machine_usb(current_machine)) { - return -1; - } - - dev = usbdevice_create(devname); - if (!dev) - return -1; - - return 0; -} - static int usb_parse(const char *cmdline) { - int r; - r = usb_device_add(cmdline); - if (r < 0) { + g_assert(machine_usb(current_machine)); + + if (!usbdevice_create(cmdline)) { error_report("could not add USB device '%s'", cmdline); + return -1; } - return r; + return 0; } /***********************************************************/