Skip to content

Commit 591e789

Browse files
authored
Merge pull request #1826 from mmorel-35/fix/contextcheck
fix: address nolint contextcheck
2 parents 7576b6f + 7166a61 commit 591e789

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

mem/mem_solaris.go

+6-9
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
2525
func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
2626
result := &VirtualMemoryStat{}
2727

28-
zoneName, err := zoneName() //nolint:contextcheck //FIXME
28+
zoneName, err := zoneName(ctx)
2929
if err != nil {
3030
return nil, err
3131
}
3232

3333
if zoneName == "global" {
34-
capacity, err := globalZoneMemoryCapacity() //nolint:contextcheck //FIXME
34+
capacity, err := globalZoneMemoryCapacity(ctx)
3535
if err != nil {
3636
return nil, err
3737
}
@@ -44,7 +44,7 @@ func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) {
4444
result.Free = freemem
4545
result.Used = result.Total - result.Free
4646
} else {
47-
capacity, err := nonGlobalZoneMemoryCapacity() //nolint:contextcheck //FIXME
47+
capacity, err := nonGlobalZoneMemoryCapacity(ctx)
4848
if err != nil {
4949
return nil, err
5050
}
@@ -62,8 +62,7 @@ func SwapMemoryWithContext(_ context.Context) (*SwapMemoryStat, error) {
6262
return nil, common.ErrNotImplementedError
6363
}
6464

65-
func zoneName() (string, error) {
66-
ctx := context.Background()
65+
func zoneName(ctx context.Context) (string, error) {
6766
out, err := invoke.CommandWithContext(ctx, "zonename")
6867
if err != nil {
6968
return "", err
@@ -74,8 +73,7 @@ func zoneName() (string, error) {
7473

7574
var globalZoneMemoryCapacityMatch = regexp.MustCompile(`[Mm]emory size: (\d+) Megabytes`)
7675

77-
func globalZoneMemoryCapacity() (uint64, error) {
78-
ctx := context.Background()
76+
func globalZoneMemoryCapacity(ctx context.Context) (uint64, error) {
7977
out, err := invoke.CommandWithContext(ctx, "prtconf")
8078
if err != nil {
8179
return 0, err
@@ -115,8 +113,7 @@ func globalZoneFreeMemory(ctx context.Context) (uint64, error) {
115113

116114
var kstatMatch = regexp.MustCompile(`(\S+)\s+(\S*)`)
117115

118-
func nonGlobalZoneMemoryCapacity() (uint64, error) {
119-
ctx := context.Background()
116+
func nonGlobalZoneMemoryCapacity(ctx context.Context) (uint64, error) {
120117
out, err := invoke.CommandWithContext(ctx, "kstat", "-p", "-c", "zone_memory_cap", "memory_cap:*:*:physcap")
121118
if err != nil {
122119
return 0, err

0 commit comments

Comments
 (0)