aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/earlyinit/modprobe.go4
-rw-r--r--cmd/hakurei/json.go11
-rw-r--r--cmd/mbf/internal/pkgserver/search.go2
-rw-r--r--cmd/sharefs/fuse.go4
4 files changed, 11 insertions, 10 deletions
diff --git a/cmd/earlyinit/modprobe.go b/cmd/earlyinit/modprobe.go
index 5a9868d4..8addf973 100644
--- a/cmd/earlyinit/modprobe.go
+++ b/cmd/earlyinit/modprobe.go
@@ -57,8 +57,8 @@ func dispatchModprobe(
continue
}
- var exitError *exec.ExitError
- if !errors.As(err, &exitError) || exitError == nil {
+ exitError, ok := errors.AsType[*exec.ExitError](err)
+ if !ok || exitError == nil {
r.Dispatch(report.Degraded, "invoke modprobe", err)
continue
}
diff --git a/cmd/hakurei/json.go b/cmd/hakurei/json.go
index 30eb4334..d0d978d3 100644
--- a/cmd/hakurei/json.go
+++ b/cmd/hakurei/json.go
@@ -7,7 +7,8 @@ import (
"strconv"
)
-// decodeJSON decodes json from r and stores it in v. A non-nil error results in a call to fatal.
+// decodeJSON decodes json from r and stores it in v. A non-nil error results in
+// a call to fatal.
func decodeJSON(fatal func(v ...any), op string, r io.Reader, v any) {
err := json.NewDecoder(r).Decode(v)
if err == nil {
@@ -47,14 +48,14 @@ func encodeJSON(fatal func(v ...any), output io.Writer, short bool, v any) {
}
if err := encoder.Encode(v); err != nil {
- var marshalerError *json.MarshalerError
- if errors.As(err, &marshalerError) && marshalerError != nil {
+ if e, ok := errors.AsType[*json.MarshalerError](err); ok && e != nil {
// this likely indicates an implementation error in hst
- fatal("cannot encode json for " + marshalerError.Type.String() + ": " + marshalerError.Err.Error())
+ fatal("cannot encode json for " + e.Type.String() + ": " + e.Err.Error())
return
}
- // UnsupportedTypeError, UnsupportedValueError: incorrect usage, does not need to be handled
+ // UnsupportedTypeError, UnsupportedValueError: incorrect usage, does
+ // not need to be handled
fatal("cannot write json: " + err.Error())
}
}
diff --git a/cmd/mbf/internal/pkgserver/search.go b/cmd/mbf/internal/pkgserver/search.go
index 5756512f..15947804 100644
--- a/cmd/mbf/internal/pkgserver/search.go
+++ b/cmd/mbf/internal/pkgserver/search.go
@@ -74,7 +74,7 @@ func (s *searchCache) clean() {
}
func indexsum(in [][]int) int {
sum := 0
- for i := 0; i < len(in); i++ {
+ for i := range in {
sum += in[i][1] - in[i][0]
}
return sum
diff --git a/cmd/sharefs/fuse.go b/cmd/sharefs/fuse.go
index c9855eb7..5dfbf385 100644
--- a/cmd/sharefs/fuse.go
+++ b/cmd/sharefs/fuse.go
@@ -508,8 +508,8 @@ func _main(s ...string) (exitCode int) {
if !z.AllowOrphan {
if err := z.Wait(); err != nil {
- var exitError *exec.ExitError
- if !errors.As(err, &exitError) || exitError == nil {
+ exitError, ok := errors.AsType[*exec.ExitError](err)
+ if !ok || exitError == nil {
log.Println(err)
return 5
}