Skip to content

Commit

Permalink
libmem: golangci-lint fixes.
Browse files Browse the repository at this point in the history
Signed-off-by: Krisztian Litkey <[email protected]>
  • Loading branch information
klihub committed Dec 10, 2024
1 parent 331b1ec commit 5a4f2f6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 19 deletions.
10 changes: 8 additions & 2 deletions pkg/resmgr/lib/memory/allocator.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,10 @@ func (a *Allocator) allocate(req *Request) (retErr error) {

defer func() {
if retErr != nil {
a.revertJournal(req)
_, err := a.revertJournal(req)
if err != nil {
log.Warn("failed to revert journal on error: %v", err)
}
}
}()

Expand Down Expand Up @@ -337,7 +340,10 @@ func (a *Allocator) realloc(req *Request, nodes NodeMask, types TypeMask) (zone

defer func() {
if retErr != nil {
a.revertJournal(nil)
_, err := a.revertJournal(nil)
if err != nil {
log.Warn("failed to revert journal on error: %v", err)
}
}
}()

Expand Down
13 changes: 1 addition & 12 deletions pkg/resmgr/lib/memory/allocator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package libmem_test

import (
"fmt"
"strconv"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -1155,7 +1154,7 @@ func TestRealloc(t *testing.T) {
require.Equal(t, tc.updates, updates, "updated nodes")
}

nodes, updates, err = a.Realloc(tc.id, tc.newNodes, tc.newTypes)
nodes, _, err = a.Realloc(tc.id, tc.newNodes, tc.newTypes)

if !tc.fail {
require.Nil(t, err, "unexpected realloc failure")
Expand Down Expand Up @@ -1451,13 +1450,3 @@ func (s *testSetup) nodes(t *testing.T) []*Node {

return nodes
}

var (
nextID = 1
)

func newID() string {
id := strconv.Itoa(nextID)
nextID++
return id
}
1 change: 0 additions & 1 deletion pkg/resmgr/lib/memory/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func TestHumanReadableSize(t *testing.T) {
func TestRequestString(t *testing.T) {
type testCase struct {
name string
aff NodeMask
req *Request
result string
}
Expand Down
4 changes: 0 additions & 4 deletions pkg/resmgr/lib/memory/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,6 @@ const (
TypeMaskAll TypeMask = (TypeMaskHBM << 1) - 1 // all types of memory
)

var (
typeMaskToString map[TypeMask]string
)

// NewTypeMask returns a TypeMask containing the given memory types.
func NewTypeMask(types ...Type) TypeMask {
m := TypeMask(0)
Expand Down

0 comments on commit 5a4f2f6

Please sign in to comment.