From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1176498-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 584C513835A
	for <garchives@archives.gentoo.org>; Tue,  2 Jun 2020 21:54:15 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 9E42CE0839;
	Tue,  2 Jun 2020 21:54:14 +0000 (UTC)
Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 88D23E0839
	for <gentoo-commits@lists.gentoo.org>; Tue,  2 Jun 2020 21:54:14 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 6AA8E34EF3C
	for <gentoo-commits@lists.gentoo.org>; Tue,  2 Jun 2020 21:54:13 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 18AB823B
	for <gentoo-commits@lists.gentoo.org>; Tue,  2 Jun 2020 21:54:12 +0000 (UTC)
From: "Robin H. Johnson" <robbat2@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Robin H. Johnson" <robbat2@gentoo.org>
Message-ID: <1591134297.1c846d9d8e23d94046df471c7ccbb88228537188.robbat2@OpenRC>
Subject: [gentoo-commits] proj/netifrc:master commit in: net/
X-VCS-Repository: proj/netifrc
X-VCS-Files: net/iw.sh
X-VCS-Directories: net/
X-VCS-Committer: robbat2
X-VCS-Committer-Name: Robin H. Johnson
X-VCS-Revision: 1c846d9d8e23d94046df471c7ccbb88228537188
X-VCS-Branch: master
Date: Tue,  2 Jun 2020 21:54:12 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: cfd1b11a-017a-40be-9ada-1f45e6100221
X-Archives-Hash: 614b0f11d42cf8bde4b4977c453e3d43

commit:     1c846d9d8e23d94046df471c7ccbb88228537188
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Tue Jun  2 21:44:26 2020 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Tue Jun  2 21:44:57 2020 +0000
URL:        https://gitweb.gentoo.org/proj/netifrc.git/commit/?id=1c846d9d

net/iw: refactor iw mode setup

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 net/iw.sh | 37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/net/iw.sh b/net/iw.sh
index 82b9ba9..dcdbb79 100644
--- a/net/iw.sh
+++ b/net/iw.sh
@@ -585,27 +585,30 @@ iw_configure()
 	[ -z "${SSID}" ] && eval SSID=\$essid_${IFVAR}
 
 	# Setup ad-hoc mode?
-	eval x=\$mode_${IFVAR}
-	x=${x:-managed}
+	eval _mode=\$mode_${IFVAR}
+	_mode=${_mode:-managed}
 
-	if [ "${x}" = "master" ]; then
-		eerror "Please use hostapd to make this interface an access point"
-		return 1
-	fi
-
-	if [ "${x}" = "ad-hoc" ]; then
-		iw_setup_adhoc
-		return $?
-	fi
-
-	if [ "${x}" != "managed" ]; then
-		eerror "Only managed and ad-hoc are supported"
-		return 1
-	fi
+	case "${_mode}" in
+		master)
+			eerror "Please use hostapd to make this interface an access point"
+			return 1
+			;;
+		ad-hoc|adhoc)
+			iw_setup_adhoc
+			return $?
+			;;
+		managed)
+			# Fall through
+			;;
+		*)
+			eerror "Only managed and ad-hoc are supported"
+			return 1
+			;;
+	esac
 
 	# Has an SSID been forced?
 	if [ -n "${SSID}" ]; then
-		iw_set_mode "${x}"
+		iw_set_mode "${_mode}"
 		iw_associate && return 0
 		[ "${SSID}" = "any" ] && iw_force_preferred && return 0