From patchwork Tue Jan 14 11:37:53 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: 857242 Delivered-To: patch@linaro.org Received: by 2002:a5d:525c:0:b0:385:e875:8a9e with SMTP id k28csp1872921wrc; Tue, 14 Jan 2025 03:42:31 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXC3fuhmF3N9VXfcrXgTKMR3hjFSsy1TdcRN/KE0TwukKNZFQ1ljDyNGYxaM6Ov5DWht10Jqg==@linaro.org X-Google-Smtp-Source: AGHT+IHN70nCcY3184Nt2mD82zusIEtA1kJdfue5zIixcNjX3gu3uNBsaNNLtP6J/5RU0WO0MYYS X-Received: by 2002:a05:620a:2805:b0:7b8:5511:f72d with SMTP id af79cd13be357-7bce11d8853mr3273223785a.17.1736854951260; Tue, 14 Jan 2025 03:42:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1736854951; cv=none; d=google.com; s=arc-20240605; b=iGsks9vlBg0PyNoZPZg0XVWqcLAYFgEyg5/cNcBuh0P8VoDQYBw74b4wfSAO0IfZRG wWrpRbu83Wa7Rqda4RExTJfYtYXum7V+/zJANxHyhO2NLv/OO2v2YWH11ZGFhb8s31eO Srmt6gPHWheT2hYfTlNp6b58dnm+EDpQP5kZppT3nYsoPIzt5jEY2KcnCFvn23KdZZaj rVR8630EVLGUmESNO0n+jpCV6q9wosUqL0Qxbpm/ATyZjWe4vBJWDJfspyzxIgqD2Vtg SMPfNeca+K7nRw4w6S+/dmfwtlYC+1ivG0hNwBKoPN83oqVLu9TfwqFxuEuFREvso1BU przQ== 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=JhuWbz37w1Y1jozAto2PdaStriGQyF5dVt49ZcJCRfQ=; fh=VYvYiHvFbbCWTykUc/bt4crdK8jDyKaZUHo+pY28okQ=; b=OobfhX2k41UKnxx38Nnolbqiobbc9C7m9VxsUdg9Qlhg0Nb1Kuo11pzaSfW0JNfRrM E9WbTlrD7qaK4dJ7PKUxYgeWVfpZR+FSfizaxWgZZG/eXdO+QCHgDKCp8lkzd8NF1fXl EzMoHIUITtkFy3naVY+URhENhaPmIgEHZ5LSN5hupIzDQOwanX5+CxaIi/KE/IPBbvyN ArDdMSfftWhfkPEstxp8039tBjOe5dkKgrX0m5GkycS5qRv9fdYEzYHd9JrB976xp1Ig HzwpKiPKzwo9fJwrqOOvJwnlM5Q7xOiEIgKMAUuAoxxL+1NQo9zcC55DCF5ed3PuMR5A x80Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wrPmxuh5; 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 af79cd13be357-7bce322a6efsi1371172585a.133.2025.01.14.03.42.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 14 Jan 2025 03:42:31 -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=wrPmxuh5; 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 1tXfFt-0005C1-0g; Tue, 14 Jan 2025 06:38:45 -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 1tXfFg-00056y-Df for qemu-devel@nongnu.org; Tue, 14 Jan 2025 06:38:32 -0500 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tXfFe-0005Q4-G5 for qemu-devel@nongnu.org; Tue, 14 Jan 2025 06:38:32 -0500 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-5d3d14336f0so9218364a12.3 for ; Tue, 14 Jan 2025 03:38:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1736854709; x=1737459509; 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=JhuWbz37w1Y1jozAto2PdaStriGQyF5dVt49ZcJCRfQ=; b=wrPmxuh5qgxEsvFT/w9ColFq7CFUTz2nSqDz4VR5zEiLpR7Zk+bkpPaiZRRkvY4r2Q uVgihEo8WKGuR1k30pR8/jU2h7eTSaWmel3nPZFTWIhpD+NTTS+5mymjiIQPBKss8T+m O3qI257pqgMb3Ga+39+tp5g8EcoeTB8aQhQVIAP0DNDNze7+gzL4EKl6QTzvmwddZfHz 3xD4HkZJlnD+gb0mztEy2htxd+UsxA+IGSQKS4X4ChsLH+a1axpiH8gxiWiTKLSlv13B 2cTxW8rwgmmCAcNiWgrnuyAcw62BKPACBs6hHSO6SQu/5dmzRN4fPvCfDlFj5r5XjO2d nZBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736854709; x=1737459509; 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=JhuWbz37w1Y1jozAto2PdaStriGQyF5dVt49ZcJCRfQ=; b=m8xmPMoOAzqP3yJgty9XGmWdvYOtBNJAQPfR15WtaK6BG/o8puuu4Uxvt3jBj5PYTh VmxjK7ujpWEQkCjMd6s2377PYejqySxTDfbjwYUpXLf7vBJzPCXvDs8Nye0Yh7xMZ8F3 e/7QPIlNjdAnS1dhvoiRv0farjjzWBEDEvF9ulhPuOcLfUbkx2T9tVvWUFNTvPdzOvmi domUr0FcQop7GOX/VjQajuH0Qmh9cJznZT/2FXBRPknvtdhbHzKBQDpY6H6DCCQO3EhM Iui1RFrZ8i4eUb6245C+pqPvtHp7IGsLq7OOIRLGtbKn4ERq43WbChINC1CrDteYeotv lg5Q== X-Gm-Message-State: AOJu0YyqEpnGMNBJcBaFt3X8nQpc8Br3BPKv//u9VTGGqFqVMo7ItJkm iIKAHyMFcScQmavlw26JGWF2ec2aeQJMPYVtRYj+Kz2CZu4n9n3n2jLvh4nayF9meuEac5jTGls B8v0= X-Gm-Gg: ASbGncvwygms+rTwcPLZ2JeCSXbLXrpqq21bFRoW2hnUY5N3YxqOL98C6+oDhGqy0LW r5Iu3gEf4s4tLicxMG5CeAkSDKd539v5i9sdb4MHcB4O0n2zgOzRLywYYAE2NyD+MgoP4y3TRMK bkZG3CgPFMv6G+d8x+YYWgS7PXxKq1CemiGFSRZZ17LgPbQm5xJpzKekN/gXMbLddF8Q9lZR18c dvlf7ACKUZrTQTymE6zcqbs5rtcr5S+tSLNy9Hwz4EGcfTHOT7QzkU= X-Received: by 2002:a05:6402:540e:b0:5d0:b51c:8478 with SMTP id 4fb4d7f45d1cf-5d972e0e274mr22202061a12.12.1736854708901; Tue, 14 Jan 2025 03:38:28 -0800 (PST) Received: from draig.lan ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d99008c37csm6173423a12.6.2025.01.14.03.38.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jan 2025 03:38:26 -0800 (PST) Received: from draig.lan (localhost [IPv6:::1]) by draig.lan (Postfix) with ESMTP id 946EF5F9D8; Tue, 14 Jan 2025 11:38:22 +0000 (GMT) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Stefan Weil , Pierrick Bouvier , =?utf-8?q?Alex_Benn=C3=A9e?= , Paolo Bonzini Subject: [PATCH v2 09/37] system: squash usb_parse into a single function Date: Tue, 14 Jan 2025 11:37:53 +0000 Message-Id: <20250114113821.768750-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250114113821.768750-1-alex.bennee@linaro.org> References: <20250114113821.768750-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::530; envelope-from=alex.bennee@linaro.org; helo=mail-ed1-x530.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. Message-Id: <20250109170619.2271193-10-alex.bennee@linaro.org> Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Alex Bennée --- system/vl.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/system/vl.c b/system/vl.c index 7e3e6fb353..e769132ba3 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 */