From b4a7ce86cf941038710e7767e0d200c0521c3d25 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sat, 7 Mar 2020 21:48:59 +0100 Subject: [PATCH] uint cannot be less than zero --- internal/archiver/archiver_test.go | 4 ++-- internal/backend/semaphore.go | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/internal/archiver/archiver_test.go b/internal/archiver/archiver_test.go index e84d4c0b9..6fc5ab648 100644 --- a/internal/archiver/archiver_test.go +++ b/internal/archiver/archiver_test.go @@ -832,7 +832,7 @@ func TestArchiverSaveDir(t *testing.T) { if stats.DataBlobs != 0 { t.Errorf("wrong stats returned in DataBlobs, want 0, got %d", stats.DataBlobs) } - if stats.TreeSize <= 0 { + if stats.TreeSize == 0 { t.Errorf("wrong stats returned in TreeSize, want > 0, got %d", stats.TreeSize) } if stats.TreeBlobs <= 0 { @@ -910,7 +910,7 @@ func TestArchiverSaveDirIncremental(t *testing.T) { if stats.DataBlobs != 0 { t.Errorf("wrong stats returned in DataBlobs, want 0, got %d", stats.DataBlobs) } - if stats.TreeSize <= 0 { + if stats.TreeSize == 0 { t.Errorf("wrong stats returned in TreeSize, want > 0, got %d", stats.TreeSize) } if stats.TreeBlobs <= 0 { diff --git a/internal/backend/semaphore.go b/internal/backend/semaphore.go index 2146db2f3..28b97472b 100644 --- a/internal/backend/semaphore.go +++ b/internal/backend/semaphore.go @@ -2,8 +2,9 @@ package backend import ( "context" - "github.com/restic/restic/internal/errors" "io" + + "github.com/restic/restic/internal/errors" ) // Semaphore limits access to a restricted resource. @@ -13,7 +14,7 @@ type Semaphore struct { // NewSemaphore returns a new semaphore with capacity n. func NewSemaphore(n uint) (*Semaphore, error) { - if n <= 0 { + if n == 0 { return nil, errors.New("must be a positive number") } return &Semaphore{