naccyde / rpms / iproute

Forked from rpms/iproute 7 months ago
Clone

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

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