naccyde / rpms / iproute

Forked from rpms/iproute 5 months ago
Clone

Blame SOURCES/0004-configure-simplify-options-parsing.patch

6548d8
From 1b4bdce40f9244823c464f2a36a0db7cd6ba427b Mon Sep 17 00:00:00 2001
6548d8
Message-Id: <1b4bdce40f9244823c464f2a36a0db7cd6ba427b.1637678195.git.aclaudi@redhat.com>
6548d8
In-Reply-To: <b30268eda844bdebbb8e5e4f5735e3b1bb666368.1637678195.git.aclaudi@redhat.com>
6548d8
References: <b30268eda844bdebbb8e5e4f5735e3b1bb666368.1637678195.git.aclaudi@redhat.com>
6548d8
From: Andrea Claudi <aclaudi@redhat.com>
6548d8
Date: Tue, 23 Nov 2021 15:28:18 +0100
6548d8
Subject: [PATCH] configure: simplify options parsing
6548d8
6548d8
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2016061
6548d8
Upstream Status: iproute2.git commit 99245d17
6548d8
6548d8
commit 99245d1741a85e4397973782578d4a78673eb348
6548d8
Author: Andrea Claudi <aclaudi@redhat.com>
6548d8
Date:   Thu Oct 14 10:50:52 2021 +0200
6548d8
6548d8
    configure: simplify options parsing
6548d8
6548d8
    This commit simplifies options parsing moving all the code not related to
6548d8
    parsing out of the case statement.
6548d8
6548d8
    - The conditional shift after the assignments is moved right after the
6548d8
      case, reducing code duplication.
6548d8
    - The semantic checks on the LIBBPF_FORCE value is moved after the loop
6548d8
      like we already did for INCLUDE and LIBBPF_DIR.
6548d8
    - Finally, the loop condition is changed to check remaining arguments, thus
6548d8
      making it possible to get rid of the null string case break.
6548d8
6548d8
    As a bonus, now the help message states that on or off should follow
6548d8
    --libbpf_force
6548d8
6548d8
    Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
6548d8
    Acked-by: Phil Sutter <phil@nwl.cc>
6548d8
    Signed-off-by: David Ahern <dsahern@kernel.org>
6548d8
---
6548d8
 configure | 37 ++++++++++++++++++-------------------
6548d8
 1 file changed, 18 insertions(+), 19 deletions(-)
6548d8
6548d8
diff --git a/configure b/configure
6548d8
index 9ec19a5b..26e06eb8 100755
6548d8
--- a/configure
6548d8
+++ b/configure
6548d8
@@ -485,12 +485,12 @@ usage()
6548d8
 {
6548d8
 	cat <
6548d8
 Usage: $0 [OPTIONS]
6548d8
-	--include_dir <dir>	Path to iproute2 include dir
6548d8
-	--libbpf_dir <dir>	Path to libbpf DESTDIR
6548d8
-	--libbpf_force		Enable/disable libbpf by force. Available options:
6548d8
-				  on: require link against libbpf, quit config if no libbpf support
6548d8
-				  off: disable libbpf probing
6548d8
-	-h | --help		Show this usage info
6548d8
+	--include_dir <dir>		Path to iproute2 include dir
6548d8
+	--libbpf_dir <dir>		Path to libbpf DESTDIR
6548d8
+	--libbpf_force <on|off>		Enable/disable libbpf by force. Available options:
6548d8
+					  on: require link against libbpf, quit config if no libbpf support
6548d8
+					  off: disable libbpf probing
6548d8
+	-h | --help			Show this usage info
6548d8
 EOF
6548d8
 	exit $1
6548d8
 }
6548d8
@@ -499,31 +499,25 @@ EOF
6548d8
 if [ $# -eq 1 ] && [ "$(echo $1 | cut -c 1)" != '-' ]; then
6548d8
 	INCLUDE="$1"
6548d8
 else
6548d8
-	while true; do
6548d8
+	while [ "$#" -gt 0 ]; do
6548d8
 		case "$1" in
6548d8
 			--include_dir)
6548d8
 				shift
6548d8
-				INCLUDE="$1"
6548d8
-				[ "$#" -gt 0 ] && shift ;;
6548d8
+				INCLUDE="$1" ;;
6548d8
 			--libbpf_dir)
6548d8
 				shift
6548d8
-				LIBBPF_DIR="$1"
6548d8
-				[ "$#" -gt 0 ] && shift ;;
6548d8
+				LIBBPF_DIR="$1" ;;
6548d8
 			--libbpf_force)
6548d8
-				if [ "$2" != 'on' ] && [ "$2" != 'off' ]; then
6548d8
-					usage 1
6548d8
-				fi
6548d8
-				LIBBPF_FORCE=$2
6548d8
-				shift 2 ;;
6548d8
+				shift
6548d8
+				LIBBPF_FORCE="$1" ;;
6548d8
 			-h | --help)
6548d8
 				usage 0 ;;
6548d8
 			--*)
6548d8
-				shift ;;
6548d8
-			"")
6548d8
-				break ;;
6548d8
+				;;
6548d8
 			*)
6548d8
 				usage 1 ;;
6548d8
 		esac
6548d8
+		[ "$#" -gt 0 ] && shift
6548d8
 	done
6548d8
 fi
6548d8
 
6548d8
@@ -531,6 +525,11 @@ fi
6548d8
 if [ "${LIBBPF_DIR-unused}" != "unused" ]; then
6548d8
 	[ -d "$LIBBPF_DIR" ] || usage 1
6548d8
 fi
6548d8
+if [ "${LIBBPF_FORCE-unused}" != "unused" ]; then
6548d8
+	if [ "$LIBBPF_FORCE" != 'on' ] && [ "$LIBBPF_FORCE" != 'off' ]; then
6548d8
+		usage 1
6548d8
+	fi
6548d8
+fi
6548d8
 
6548d8
 echo "# Generated config based on" $INCLUDE >$CONFIG
6548d8
 quiet_config >> $CONFIG
6548d8
-- 
6548d8
2.31.1
6548d8