aboutsummaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2025-01-17 10:28:16 +0100
committerDmitry Vyukov <dvyukov@google.com>2025-01-17 10:02:07 +0000
commit5d04aae8969f6c72318ce0a4cde4f027766b1a55 (patch)
tree8f1b632847c431407090f0fe1335522ff2195a37 /sys
parentf9e07a6e597b68d3397864e6ee4550f9065c3518 (diff)
all: use min/max functions
They are shorter, more readable, and don't require temp vars.
Diffstat (limited to 'sys')
-rw-r--r--sys/openbsd/init.go8
-rw-r--r--sys/targets/targets.go5
2 files changed, 3 insertions, 10 deletions
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
}