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

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