naccyde / rpms / iproute

Forked from rpms/iproute 5 months ago
Clone

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

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