From 5d04aae8969f6c72318ce0a4cde4f027766b1a55 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 17 Jan 2025 10:28:16 +0100 Subject: all: use min/max functions They are shorter, more readable, and don't require temp vars. --- sys/openbsd/init.go | 8 ++------ sys/targets/targets.go | 5 +---- 2 files changed, 3 insertions(+), 10 deletions(-) (limited to 'sys') diff --git a/sys/openbsd/init.go b/sys/openbsd/init.go index 2a2aeae4c..5d0c3a77c 100644 --- a/sys/openbsd/init.go +++ b/sys/openbsd/init.go @@ -196,12 +196,8 @@ func (arch *arch) neutralizeRlimit(c *prog.Call) { for _, arg := range args { switch v := arg.(type) { case *prog.ConstArg: - if v.Val < rlimitMin { - v.Val = rlimitMin - } - if v.Val > rlimitMax { - v.Val = rlimitMax - } + v.Val = max(v.Val, rlimitMin) + v.Val = min(v.Val, rlimitMax) } } } diff --git a/sys/targets/targets.go b/sys/targets/targets.go index fa2f6f0e2..c571d1165 100644 --- a/sys/targets/targets.go +++ b/sys/targets/targets.go @@ -825,10 +825,7 @@ func (target *Target) Timeouts(slowdown int) Timeouts { } timeouts := target.timeouts timeouts.Slowdown = slowdown - timeouts.Scale = time.Duration(slowdown) - if timeouts.Scale > 3 { - timeouts.Scale = 3 - } + timeouts.Scale = min(time.Duration(slowdown), 3) if timeouts.Syscall == 0 { timeouts.Syscall = 50 * time.Millisecond } -- cgit mrf-deployment