From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id C232A5A026D for ; Thu, 16 Feb 2023 06:43:22 +0100 (CET) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4PHP4L0ShMz4x8N; Thu, 16 Feb 2023 16:43:14 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1676526194; bh=Wa+DvpFct4lR3mDdvdY2o09kdScCC6Lr1OovNMT/VSA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BY4nVM9bmzfTGkrUPtbGueyjlnqTgrQd+Ay8GN3g9phJY4niL25jgDAopftQT9qjY GmwUybUA1EGwa4I+P554pd15dWmZiDnLCoCBC8QTxNQSAn3u64f9Q0xx/G3NyP4kKK SBtp7E3hYk6WnGwPsDL6YEzuEYfft8GlAA0STRDw= From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v2 2/4] tap: Eliminate goto from tap_handler() Date: Thu, 16 Feb 2023 16:43:09 +1100 Message-Id: <20230216054311.2131853-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230216054311.2131853-1-david@gibson.dropbear.id.au> References: <20230216054311.2131853-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: CV4XFWDGP45GR76LTGA3B5O2FVNMNO5D X-Message-ID-Hash: CV4XFWDGP45GR76LTGA3B5O2FVNMNO5D X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.3 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The goto here really doesn't improve clarity or brevity at all. Use a clearer construct. Signed-off-by: David Gibson --- tap.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/tap.c b/tap.c index ae60fd4..eb00135 100644 --- a/tap.c +++ b/tap.c @@ -1239,18 +1239,13 @@ void tap_handler(struct ctx *c, int fd, uint32_t events, } if ((c->mode == MODE_PASST && tap_handler_passt(c, now)) || - (c->mode == MODE_PASTA && tap_handler_pasta(c, now))) - goto reinit; - - if (events & (EPOLLRDHUP | EPOLLHUP | EPOLLERR)) - goto reinit; + (c->mode == MODE_PASTA && tap_handler_pasta(c, now)) || + (events & (EPOLLRDHUP | EPOLLHUP | EPOLLERR))) { + if (c->one_off) { + info("Client closed connection, exiting"); + exit(EXIT_SUCCESS); + } - return; -reinit: - if (c->one_off) { - info("Client closed connection, exiting"); - exit(EXIT_SUCCESS); + tap_sock_init(c); } - - tap_sock_init(c); } -- 2.39.1