diff --git a/.golangci.yml b/.golangci.yml index 3e5c436bc..153975b35 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -51,6 +51,7 @@ linters: - std-error-handling paths: - internal/gen + - internal/db/olddb - cmd/dev - repos - third_party$ diff --git a/internal/db/metrics.go b/internal/db/metrics.go index fb41124cf..abb350af3 100644 --- a/internal/db/metrics.go +++ b/internal/db/metrics.go @@ -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", diff --git a/internal/db/typed.go b/internal/db/typed.go index 75ed88921..6180e12b7 100644 --- a/internal/db/typed.go +++ b/internal/db/typed.go @@ -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 diff --git a/internal/protoutil/protoutil.go b/internal/protoutil/protoutil.go index c43057b44..3387b4da5 100644 --- a/internal/protoutil/protoutil.go +++ b/internal/protoutil/protoutil.go @@ -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 }