From patchwork Tue Oct 11 20:05:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13004314 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 61C2CC433F5 for ; Tue, 11 Oct 2022 20:16:02 +0000 (UTC) Received: from localhost ([::1]:58680 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oiLfV-00076J-5F for qemu-devel@archiver.kernel.org; Tue, 11 Oct 2022 16:16:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiLVs-0006P0-1S for qemu-devel@nongnu.org; Tue, 11 Oct 2022 16:06:05 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:52813) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oiLVp-0003ja-8U for qemu-devel@nongnu.org; Tue, 11 Oct 2022 16:06:03 -0400 Received: from lenovo-t14s.redhat.com ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1M1YtP-1okocB3Lid-0039YN; Tue, 11 Oct 2022 22:05:49 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Stefano Stabellini , =?utf-8?q?Daniel_P=2E_Berra?= =?utf-8?q?ng=C3=A9?= , "Dr. David Alan Gilbert" , Jason Wang , "Michael S. Tsirkin" , Paolo Bonzini , Anthony Perard , Greg Kurz , Eric Blake , Laurent Vivier , Stefan Weil , Thomas Huth , Samuel Thibault , Markus Armbruster , Paul Durrant , David Gibson , xen-devel@lists.xenproject.org Subject: [PATCH v11 03/17] net: simplify net_client_parse() error management Date: Tue, 11 Oct 2022 22:05:25 +0200 Message-Id: <20221011200539.1486809-4-lvivier@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221011200539.1486809-1-lvivier@redhat.com> References: <20221011200539.1486809-1-lvivier@redhat.com> MIME-Version: 1.0 X-Provags-ID: V03:K1:A9ouqfM3UJq93QDzTpjBZLmdCU8DHJePfXwKGc5MkczBHI3sW8v 8hg1116Rahdg3557QLZwWeMx2dlypFtcnm6WSWZqA1+64PK3n1gcB7RspijG0Yd38/ejcRU 6+zV5dp+TvSzYC+DcjNcbGW7mfyHPiIhKhuijsG5g5SFyDH2C+rBL0qYJSqs7DHUVgmwGnB 1D8u3TEscMxLfJXrxK6WA== X-UI-Out-Filterresults: notjunk:1;V03:K0:ln7jyWV2rEg=:P8ap6lfjsJUu5IQwLMkGnM fX7aX/43ttx5lC6LF5fVsDhsCqxOfMUT3AiMYuL+GGIzZiwIlc5GaWpx4+ESYUIn/RQW4F235 KtCawN2/RYu1EEZgnmi6vnmzq3aqSNr5JcswxUAR3sgaN73BtFzkn2o7OUNMeCWsCqlJWs7cT RQNBNv5cYxnTINJoHPCAjjbjq5zvVMQU6yPG0KtMVgJcZZyWUsr3/ECvA7DxmxTSD9jAMTT8b dnzn8PuA7siPXVL7IWGTKqoqmSeqsyRmMUSwI+n4dFoXyh2l1U76cjNUmBusiZHSQWYC+ytsv RxpEki7wHOdIxVcupm9AjjTqjVx7XlTF+D98T4FZn0RCRf4e94ZaXhO4mO/fKk3ZWQMZVZIX6 ATUc7FtpwCD4h9oy3wb7ZB4Agu0AH4/Q8is8eYEaxfde7mP9W5JAnHqIkP74SY5CNpGBeelUR arq5AeZK2HQKqTqWwmlISc5U2Gc6bmUSchTJ9CBCfw9pksZ5EbmwFxlFl4GFofL0zL19VO/Ei UVxjn6o1eAT8AviW+4IR0E+O+JTxmb1Z9vN0keMooA5rBCvhURH//tBJe3H5G4oLgnmSrmFnD DDt6yjOjPtZ25tzlOLfH4LZTQatrx4lRTOekr93kNye4M8Y53/WZDLHuz0c5TmDjEHBZSsGCT rReOOSXjzI/bGnE+kUy4PBaO8Qq19a/Azj6QOv7vsCty9Pf9HVQUbu/wXRQXMp1uHcFgVf+1+ twgPB/11Q/s9jwnVvRMC/ixzqPCPX3DnZej/iJwjfysRzcf3/epvKyG11lxEXGrA1ATUGggBW x0zLqsa Received-SPF: permerror client-ip=212.227.126.133; envelope-from=lvivier@redhat.com; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_FAIL=0.001, SPF_HELO_NONE=0.001 autolearn=no 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" All net_client_parse() callers exit in case of error. Move exit(1) to net_client_parse() and remove error checking from the callers. Suggested-by: Markus Armbruster Signed-off-by: Laurent Vivier Reviewed-by: Markus Armbruster Reviewed-by: David Gibson Acked-by: Michael S. Tsirkin --- include/net/net.h | 2 +- net/net.c | 6 ++---- softmmu/vl.c | 12 +++--------- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index c1c34a58f849..55023e7e9fa9 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -220,7 +220,7 @@ extern NICInfo nd_table[MAX_NICS]; extern const char *host_net_devices[]; /* from net.c */ -int net_client_parse(QemuOptsList *opts_list, const char *str); +void net_client_parse(QemuOptsList *opts_list, const char *str); void show_netdevs(void); void net_init_clients(void); void net_check_clients(void); diff --git a/net/net.c b/net/net.c index 15958f881776..f056e8aebfb2 100644 --- a/net/net.c +++ b/net/net.c @@ -1579,13 +1579,11 @@ void net_init_clients(void) &error_fatal); } -int net_client_parse(QemuOptsList *opts_list, const char *optarg) +void net_client_parse(QemuOptsList *opts_list, const char *optarg) { if (!qemu_opts_parse_noisily(opts_list, optarg, true)) { - return -1; + exit(1); } - - return 0; } /* From FreeBSD */ diff --git a/softmmu/vl.c b/softmmu/vl.c index a4ae131e4d61..e69aa43de469 100644 --- a/softmmu/vl.c +++ b/softmmu/vl.c @@ -2801,21 +2801,15 @@ void qemu_init(int argc, char **argv) break; case QEMU_OPTION_netdev: default_net = 0; - if (net_client_parse(qemu_find_opts("netdev"), optarg) == -1) { - exit(1); - } + net_client_parse(qemu_find_opts("netdev"), optarg); break; case QEMU_OPTION_nic: default_net = 0; - if (net_client_parse(qemu_find_opts("nic"), optarg) == -1) { - exit(1); - } + net_client_parse(qemu_find_opts("nic"), optarg); break; case QEMU_OPTION_net: default_net = 0; - if (net_client_parse(qemu_find_opts("net"), optarg) == -1) { - exit(1); - } + net_client_parse(qemu_find_opts("net"), optarg); break; #ifdef CONFIG_LIBISCSI case QEMU_OPTION_iscsi: