iproute/0004-configure-simplify-options-parsing.patch

115 lines
3.4 KiB
Diff
Raw Normal View History

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