[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <43f45a0885f28fd1d1a88122a42830dd9eeb7e2c.1754833177.git.ojaswin@linux.ibm.com>
Date: Sun, 10 Aug 2025 19:11:52 +0530
From: Ojaswin Mujoo <ojaswin@...ux.ibm.com>
To: Zorro Lang <zlang@...hat.com>, fstests@...r.kernel.org
Cc: Ritesh Harjani <ritesh.list@...il.com>, djwong@...nel.org,
john.g.garry@...cle.com, tytso@....edu, linux-xfs@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-ext4@...r.kernel.org
Subject: [PATCH v4 01/11] common/rc: Add _min() and _max() helpers
Many programs open code these functionalities so add it as a generic helper
in common/rc
Reviewed-by: Darrick J. Wong <djwong@...nel.org>
Signed-off-by: Ojaswin Mujoo <ojaswin@...ux.ibm.com>
---
common/rc | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/common/rc b/common/rc
index 96578d15..3858ddce 100644
--- a/common/rc
+++ b/common/rc
@@ -5873,6 +5873,28 @@ _require_program() {
_have_program "$1" || _notrun "$tag required"
}
+_min() {
+ local ret
+
+ for arg in "$@"; do
+ if [ -z "$ret" ] || (( $arg < $ret )); then
+ ret="$arg"
+ fi
+ done
+ echo $ret
+}
+
+_max() {
+ local ret
+
+ for arg in "$@"; do
+ if [ -z "$ret" ] || (( $arg > $ret )); then
+ ret="$arg"
+ fi
+ done
+ echo $ret
+}
+
################################################################################
# make sure this script returns success
/bin/true
--
2.49.0
Powered by blists - more mailing lists