chore(internal): linter complaints

This commit is contained in:
Jakob Borg
2025-06-06 13:45:44 +02:00
parent ef6d561c66
commit e25de22705
4 changed files with 8 additions and 4 deletions
+1
View File
@@ -51,6 +51,7 @@ linters:
- std-error-handling
paths:
- internal/gen
- internal/db/olddb
- cmd/dev
- repos
- third_party$
+1
View File
@@ -21,6 +21,7 @@ var (
Namespace: "syncthing",
Subsystem: "db",
Name: "operations_current",
Help: "Number of database operations currently ongoing, per folder and operation",
}, []string{"folder", "operation"})
metricTotalOperationSeconds = promauto.NewCounterVec(prometheus.CounterOpts{
Namespace: "syncthing",
+2 -2
View File
@@ -37,7 +37,7 @@ func NewTyped(db KV, prefix string) *Typed {
// is overwritten.
func (n *Typed) PutInt64(key string, val int64) error {
var valBs [8]byte
binary.BigEndian.PutUint64(valBs[:], uint64(val))
binary.BigEndian.PutUint64(valBs[:], uint64(val)) //nolint:gosec
return n.db.PutKV(n.prefixedKey(key), valBs[:])
}
@@ -49,7 +49,7 @@ func (n *Typed) Int64(key string) (int64, bool, error) {
return 0, false, filterNotFound(err)
}
val := binary.BigEndian.Uint64(valBs)
return int64(val), true, nil
return int64(val), true, nil //nolint:gosec
}
// PutTime stores a new time.Time. Any existing value (even if of another
+4 -2
View File
@@ -7,14 +7,16 @@
package protoutil
import (
"fmt"
"errors"
"google.golang.org/protobuf/proto"
)
var errBufferTooSmall = errors.New("buffer too small")
func MarshalTo(buf []byte, pb proto.Message) (int, error) {
if sz := proto.Size(pb); len(buf) < sz {
return 0, fmt.Errorf("buffer too small")
return 0, errBufferTooSmall
} else if sz == 0 {
return 0, nil
}