From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 7CD3E5A005E for ; Wed, 15 Feb 2023 09:24:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676449480; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4XxJDrT2onMCwF1n1R9c8fY9RNG51hoGMR6mtQkyzcM=; b=Jpl4Qls1xvusgwpFSpnDal+Fa695JVNqv8Xb2PzOk5Oh4rn7a3xi2OQq2XjSqNQ4KeZM15 6FNpGRmrQY9dugPTAAFVLVgQat92ojiuPGMawmfurgO2k1+IO7kgeCRu3WWhN1Vj0J1179 lhgHhvkNrVBK+kBHFBRYRgPGeelPWFU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-38-ISPx3HNyNT212TrZUpV10A-1; Wed, 15 Feb 2023 03:24:39 -0500 X-MC-Unique: ISPx3HNyNT212TrZUpV10A-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CE028858F09 for ; Wed, 15 Feb 2023 08:24:38 +0000 (UTC) Received: from vhost3.router.laine.org (unknown [10.2.16.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id B9F9EC15BA0 for ; Wed, 15 Feb 2023 08:24:38 +0000 (UTC) From: Laine Stump To: passt-dev@passt.top Subject: [PATCH v4 7/9] make conf_netns_opt() exit immediately after logging error Date: Wed, 15 Feb 2023 03:24:35 -0500 Message-Id: <20230215082437.110151-8-laine@redhat.com> In-Reply-To: <20230215082437.110151-1-laine@redhat.com> References: <20230215082437.110151-1-laine@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: UXR7ZR3YLZWPUMHKCFN73AL7XHU3RXU4 X-Message-ID-Hash: UXR7ZR3YLZWPUMHKCFN73AL7XHU3RXU4 X-MailFrom: laine@redhat.com 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 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: ...and return void to simplify the caller. Signed-off-by: Laine Stump --- conf.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/conf.c b/conf.c index 19020f9..d020b4f 100644 --- a/conf.c +++ b/conf.c @@ -464,10 +464,8 @@ out: * conf_netns_opt() - Parse --netns option * @netns: buffer of size PATH_MAX, updated with netns path * @arg: --netns argument - * - * Return: 0 on success, negative error code otherwise */ -static int conf_netns_opt(char *netns, const char *arg) +static void conf_netns_opt(char *netns, const char *arg) { int ret; @@ -479,12 +477,8 @@ static int conf_netns_opt(char *netns, const char *arg) ret = snprintf(netns, PATH_MAX, "%s", arg); } - if (ret <= 0 || ret > PATH_MAX) { - err("Network namespace name/path %s too long"); - return -E2BIG; - } - - return 0; + if (ret <= 0 || ret > PATH_MAX) + die("Network namespace name/path %s too long"); } /** @@ -1157,9 +1151,7 @@ void conf(struct ctx *c, int argc, char **argv) if (c->mode != MODE_PASTA) die("--netns is for pasta mode only"); - ret = conf_netns_opt(netns, optarg); - if (ret < 0) - usage(argv[0]); + conf_netns_opt(netns, optarg); break; case 4: if (c->mode != MODE_PASTA) -- 2.39.1