[PATCH blktests 1/7] common/rc: add _min()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a helper to find the minimum of two numbers.

A similar helper is being added in xfstests:
https://lore.kernel.org/linux-xfs/cover.1755849134.git.ojaswin@xxxxxxxxxxxxx/T/#m962683d8115979e57342d2644660230ee978c803

Signed-off-by: John Garry <john.g.garry@xxxxxxxxxx>
---
 common/rc | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/common/rc b/common/rc
index 946dee1..77a0f45 100644
--- a/common/rc
+++ b/common/rc
@@ -700,3 +700,14 @@ _real_dev()
 	fi
 	echo "$dev"
 }
+
+_min() {
+	local ret
+
+	for arg in "$@"; do
+		if [ -z "$ret" ] || (( $arg < $ret )); then
+			ret="$arg"
+		fi
+	done
+	echo $ret
+}
\ No newline at end of file
-- 
2.43.5





[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux