summaryrefslogtreecommitdiff
path: root/cmd/btrfs-rec/inspect/rebuildtrees/util.go
blob: 842fb550a8a84f75a90a3d4d7480c926261c6a64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Copyright (C) 2022-2023  Luke Shumaker <lukeshu@lukeshu.com>
//
// SPDX-License-Identifier: GPL-2.0-or-later

package rebuildtrees

import (
	"golang.org/x/exp/constraints"
)

func roundDown[T constraints.Integer](n, d T) T {
	return (n / d) * d
}

func roundUp[T constraints.Integer](n, d T) T {
	return ((n + d - 1) / d) * d
}

func discardOK[T any](val T, _ bool) T {
	return val
}