From patchwork Thu Jan 9 17:06:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 855983 Delivered-To: patch@linaro.org Received: by 2002:adf:8b05:0:b0:385:e875:8a9e with SMTP id n5csp1335923wra; Thu, 9 Jan 2025 09:10:25 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCUfQKjmDAFfmrd2szJbjAlK9wyulBf6sZvmStSmwmUzLD4E0ooD4R6+EW30PU2DME3u3neqdA==@linaro.org X-Google-Smtp-Source: AGHT+IFhHe0N8DNsaG5otmqfh8nuMIF/gqMMiR/y2vt3KU8EUg1eL4HDwZEH39omsDS8JFnr4B82 X-Received: by 2002:ac8:580a:0:b0:467:652a:2c77 with SMTP id d75a77b69052e-46c7107df26mr130698011cf.3.1736442625503; Thu, 09 Jan 2025 09:10:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736442625; cv=none; d=google.com; s=arc-20240605; b=TQRdNrWuZw6oiFPNFoHSZakj2p/F2YBBT8Oee1uKXdTIkFbTnfWgkexoyoFH0mGPou 7JhLnXpgo61Q28nS3fC98UY1X34DQW1CnYhhl9G+aQFRzu3n2ETHA3wa3ZwfgnnyE7K2 6gncaR8vvrXTgUwfkteYlNdCkQZpheBrYcAT5YkI68KBTkNUdu59uNm5oEa8sPmCOiQm 2oDghSLheAPHNz6V9EEhmMZI1qlPeFOQBZwNtociBWNgRrohVtXv1XfsrJ0jyjbmYQCX qI+xz+IoYwTxPiuyMUmRCwDIWndEcnZcIx5Ui2Rs7tTIBv/ObgPlmDOLfFsnYH5K1pH4 hjxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=25f+kPpL70YFXNAUtEYMY9S3pngwqu7v/kUd281l17o=; fh=FS+JTz/k+Dh1PAd9s6lkEQMFdt/HYT5+zFPDR3GvHJ0=; b=jdvuUpMTJq/VfcK0/JwrmUuaFH8crh0Hymio3vrLMpeI9eLOG87XkQ5YPn2ntrgt4n 6URLd4cxq5TNH96dioj6wdQ6DWh0GvlIeFqLPT6y+1JrM4XPhZI2ELePiUiCGZMephJy 59upRPyg5/lIGlg0V1jGVn9S6LFnmtD2iTG3kcedcN8JJvpdnr12PMoRtwe/J+IsGrcN ZHducbHsJQ4Md8R4mtcJAjOicq1694RIAN0Rm8qJUgk+vIg9WvBW5/EPjvErLaEjoB49 /FcnqH4hO/K7I0MccPeYb6bxdhSfvxFqDjqyIe5gymX2oZ/LmxNeEBaR8tgmvIpgPnjL 51FA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AaDDNfhq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-46c873312e9si548671cf.96.2025.01.09.09.10.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Jan 2025 09:10:25 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AaDDNfhq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tVvzf-0004lC-Fh; Thu, 09 Jan 2025 12:06:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tVvzU-0004iF-FZ for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:06:41 -0500 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tVvzR-0006zn-Sp for qemu-devel@nongnu.org; Thu, 09 Jan 2025 12:06:40 -0500 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-5401e6efffcso1221374e87.3 for ; Thu, 09 Jan 2025 09:06:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736442396; x=1737047196; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=25f+kPpL70YFXNAUtEYMY9S3pngwqu7v/kUd281l17o=; b=AaDDNfhq2GJblNOZTwu9syDqYPi6m+rbbpfp+M+VJ5x7XBh15wf7KUJCTUHtTGlW9Y hMeZjc+WfBauVfoxc1PQPJYTMiLfdJE0JMIPe6zcpPzJYw6gf63NE0cj8sC0PRLCrpVE vn0XeMx9BruVbMUaFltvZi332vNUw01JZkwdnJnIlxco4MrmAbOAUIhBJYXraTcTvHWN bQZR0jzbyYvuqSAtvpmGTH9fm9KcRiE4xlPyKD8h1/xUapGQ4dwq8V1wxu9/cn5GccmZ hscAgjvndGy+eMFbzZgMpm+aUw8aHVXE2VCaUya910gGDeIFaJSaJXBaH4YCtrdPISNq pCZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736442396; x=1737047196; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=25f+kPpL70YFXNAUtEYMY9S3pngwqu7v/kUd281l17o=; b=RClLXqoZ/TCFQhdDOP56yX91B0DFXCGzF5w4zNP9SeswvBSihGu6XdLT7kxRbdefrT QbPo9yi/2rBgYzKvvnVOPEZW6wVcmFXEj7PAVeLkbNQj6W+MKy5h1//2oWSiQpVy53Cs QdiTLZehLONrxFYwZcFiubyyseH0v85lH7CwNdUW5qaIPPcr97Xa6ExtHktCsAZsDSyO 6OTxMbH8TkAtPzGIMyOAQ5GHrPfY9APHXl++6npwDAEGbaIdMtqpUuX57jhB0cNYMm/t w8UiR4yKVabyp+XnOf+3v3WdpnL9JL9arHxWf2nAxnr0+eRvguuGehXtwwr8nWHvKWS7 +HNg== X-Gm-Message-State: AOJu0Yz+DL4hVrbp1IE7wYRcXC64uR872SqcjRO/guGHvb6iB9dI4zlX i2+c/Vz/Ab2FEI4lGaYLlNhiKSSvmrLqz1J6CYPvq1mqTIJpi6QzEqqsyXv1ML0= X-Gm-Gg: ASbGncsk22KqZly6YeC1XMkHlEz72sB+YlTOuAwskYoyBRTua2kz5j5fg+f8wfly7Yx ScwSihBqzMIxxcbf/YUwfXRwVx1vTrKa94eaZXQpuLwP0zy9kaC6C9yRerDeiygkiLqLvjSrNEL ZLR1KdF3YsqnYRtTVimvti2SN3fUjYNrlqgUGQWclA4dlZPKt9pBjpVI94ItnuzcWMOECc37vxi yTNfgYeFe2GXAT8Oa3ZH2yo8Mb9bPZCm8UtM+Ty5i0VzFU/fTfM2B4= X-Received: by 2002:a05:6512:2399:b0:540:1ea7:44db with SMTP id 2adb3069b0e04-542845b1aedmr2713250e87.4.1736442395726; Thu, 09 Jan 2025 09:06:35 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ab2c9562583sm87989566b.110.2025.01.09.09.06.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2025 09:06:31 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id A06125FB65; Thu, 9 Jan 2025 17:06:20 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Dr. David Alan Gilbert" , Pierrick Bouvier , =?utf-8?q?Philippe_Mathieu-?= =?utf-8?q?Daud=C3=A9?= , Thomas Huth , Mahmoud Mandour , Alexandre Iooss , Richard Henderson , Paolo Bonzini , Laurent Vivier , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH 09/22] system: squash usb_parse into a single function Date: Thu, 9 Jan 2025 17:06:06 +0000 Message-Id: <20250109170619.2271193-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250109170619.2271193-1-alex.bennee@linaro.org> References: <20250109170619.2271193-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::12f; envelope-from=alex.bennee@linaro.org; helo=mail-lf1-x12f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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. Signed-off-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé --- system/vl.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/system/vl.c b/system/vl.c index 25d9968ccc..df59cff865 100644 --- a/system/vl.c +++ b/system/vl.c @@ -811,31 +811,17 @@ static void configure_msg(QemuOpts *opts) /***********************************************************/ /* USB devices */ -static int usb_device_add(const char *devname) +static int usb_parse(const char *cmdline) { - USBDevice *dev = NULL; + g_assert(machine_usb(current_machine)); - if (!machine_usb(current_machine)) { + if (!usbdevice_create(cmdline)) { + error_report("could not add USB device '%s'", cmdline); 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) { - error_report("could not add USB device '%s'", cmdline); - } - return r; -} - /***********************************************************/ /* machine registration */