From patchwork Thu Oct 20 09:16:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13012938 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 C7E74C433FE for ; Thu, 20 Oct 2022 09:52:42 +0000 (UTC) Received: from localhost ([::1]:41004 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olSED-0003SM-Jv for qemu-devel@archiver.kernel.org; Thu, 20 Oct 2022 05:52:41 -0400 Received: from [::1] (helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1olRpb-0001x4-Uy for qemu-devel@archiver.kernel.org; Thu, 20 Oct 2022 05:27:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50484) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olRfY-0002ZC-6S for qemu-devel@nongnu.org; Thu, 20 Oct 2022 05:16:52 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:54509) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1olRfT-0005Hs-K1 for qemu-devel@nongnu.org; Thu, 20 Oct 2022 05:16:50 -0400 Received: from lenovo-t14s.redhat.com ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N63NQ-1p9sIG1hkm-016OzW; Thu, 20 Oct 2022 11:16:36 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , xen-devel@lists.xenproject.org, Eric Blake , Stefano Stabellini , Paolo Bonzini , Greg Kurz , Jason Wang , Anthony Perard , Thomas Huth , David Gibson , "Michael S. Tsirkin" , Laurent Vivier , Samuel Thibault , "Dr. David Alan Gilbert" , Paul Durrant , Stefan Weil , Markus Armbruster Subject: [PATCH v12 03/17] net: simplify net_client_parse() error management Date: Thu, 20 Oct 2022 11:16:10 +0200 Message-Id: <20221020091624.48368-4-lvivier@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221020091624.48368-1-lvivier@redhat.com> References: <20221020091624.48368-1-lvivier@redhat.com> MIME-Version: 1.0 X-Provags-ID: V03:K1:4+NFKSFp2Hij0apaps/Q2/rgGc65iwBfvVhBoGdLBuqqtEwusC+ q0jNyFjcVAi6iQic8jBMtjYjKLmz/ULbh4oSvJeTiOjSOPkOvQs0quJnczPXxei7Wdqez3v vhd/NixhpoJaSNFv80dHO+BZ9caakqorWtZoUeW8+Pu3rOHyy9fvr0XtdAbu9koYTcxPavE hcqc0pXAUecXdcxTKPVQA== X-UI-Out-Filterresults: notjunk:1;V03:K0:iiuq1lxlvJU=:nysntMu7Wj00UYdxw8Xhpt MaPLgD3i/jHiAlOnBA9XhZTAg7pcQHrPaQZuUcEafIdg4x8FkefKXLSelNP843i0tWC//x5nb R6IBUVMany+OkZfHAJXHQXyB4YuYen+1Ejg674gPuCyZF8zIKv26OUpWBdEU2/cSfNsKNE0tr Q4LV8XQ/Im1zQ0v9DcCVtTAoJRL8LHt8Ebx8NZPSUpNZNdAYOPQ3efdaxGiPuxcDqRTA0EhJO XAJ9g8NCsaMqB3Skj1LM7Z+ig7TNnhaFWJo+fs6DrTLOJM7VpGH+T9AE/ErMV8XO1SEjj0iIF CiXCcyeor1rzKlPpwg3QHhHUbWXGCyY/1COahsWzuhU+c36pz0QDmvzjsPxGI3p0t5dzyJB1z ejjKQgIaM1BgCwqQxs09VMuSRwmw4vHcYrM9L1/DHGCyQZYNZ3JmkM9/ZrH2v2rNcdqLDwBEf hCYDHhCzuCOAu+D2cOq9/Ryb3rnEEoh+C2vS9nIvSfcSR1nhu6FdJTsU3XHYBAMxXlh61b6be 2KO+6e6fis5TFDZxZnn1C6R5iCdKqzbg4LjQGfmQdfp3T/zOheyeQ0nMWwtl1K0rYipFjmaT2 3IutMyfT+EYO/Kma3dgdawzSx6Jss9d/DsNM5W3CuK9HBlhAKp/j+Geoew4AJfWfTKqKDfqhn sSzFY4dduGQ3FS90VXfs6sMhJ6eJOXDG4TK8Gz7Vs8mbCZSf9zfgWKgwcrpbHGBQxGrG6bZqx Ypl4DUX3FUTAxRaBJFOTQI1UWnfmjaayIXJ/I+QWvZOQN6rFRYE97R/iZvMGYul8jS6yd4B4L +OPbakG 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: