uint cannot be less than zero

This commit is contained in:
Michael Eischer 2020-03-07 21:48:59 +01:00
parent 7ee0964880
commit b4a7ce86cf
2 changed files with 5 additions and 4 deletions

View file

@ -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 {

View file

@ -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{