Skip to content

Commit 07d6dc8

Browse files
committed
chore: enable hugeParam from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
1 parent 2079fce commit 07d6dc8

9 files changed

Lines changed: 16 additions & 17 deletions

File tree

.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ linters:
4444
- commentedOutCode
4545
- deferInLoop
4646
- hexLiteral
47-
- hugeParam
4847
- tooManyResultsChecker
4948
- unnamedResult
5049
enable-all: true

cpu/cpu.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ func (c TimesStat) String() string {
9191

9292
// Deprecated: Total returns the total number of seconds in a CPUTimesStat
9393
// Please do not use this internal function.
94-
func (c TimesStat) Total() float64 {
94+
func (c *TimesStat) Total() float64 {
9595
total := c.User + c.System + c.Idle + c.Nice + c.Iowait + c.Irq +
9696
c.Softirq + c.Steal + c.Guest + c.GuestNice
9797

@@ -103,7 +103,7 @@ func (c InfoStat) String() string {
103103
return string(s)
104104
}
105105

106-
func getAllBusy(t TimesStat) (float64, float64) {
106+
func getAllBusy(t *TimesStat) (float64, float64) {
107107
tot := t.Total()
108108
if runtime.GOOS == "linux" {
109109
tot -= t.Guest // Linux 2.6.24+
@@ -115,7 +115,7 @@ func getAllBusy(t TimesStat) (float64, float64) {
115115
return tot, busy
116116
}
117117

118-
func calculateBusy(t1, t2 TimesStat) float64 {
118+
func calculateBusy(t1, t2 *TimesStat) float64 {
119119
t1All, t1Busy := getAllBusy(t1)
120120
t2All, t2Busy := getAllBusy(t2)
121121

@@ -139,7 +139,7 @@ func calculateAllBusy(t1, t2 []TimesStat) ([]float64, error) {
139139

140140
ret := make([]float64, len(t1))
141141
for i, t := range t2 {
142-
ret[i] = calculateBusy(t1[i], t)
142+
ret[i] = calculateBusy(&t1[i], &t)
143143
}
144144
return ret, nil
145145
}

disk/disk_aix_nocgo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func PartitionsWithContext(ctx context.Context, _ bool) ([]PartitionStat, error)
8080
return ret, nil
8181
}
8282

83-
func getFsType(stat unix.Statfs_t) string {
83+
func getFsType(stat *unix.Statfs_t) string {
8484
return FSType[int(stat.Vfstype)]
8585
}
8686

disk/disk_darwin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func PartitionsWithContext(_ context.Context, _ bool) ([]PartitionStat, error) {
8787
return ret, nil
8888
}
8989

90-
func getFsType(stat unix.Statfs_t) string {
90+
func getFsType(stat *unix.Statfs_t) string {
9191
return common.ByteToString(stat.Fstypename[:])
9292
}
9393

disk/disk_freebsd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ func parsedevstat(buf []byte) (devstat, error) {
163163
return ds, nil
164164
}
165165

166-
func getFsType(stat unix.Statfs_t) string {
166+
func getFsType(stat *unix.Statfs_t) string {
167167
return common.ByteToString(stat.Fstypename[:])
168168
}
169169

disk/disk_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ func LabelWithContext(ctx context.Context, name string) (string, error) {
573573
return label, nil
574574
}
575575

576-
func getFsType(stat unix.Statfs_t) string {
576+
func getFsType(stat *unix.Statfs_t) string {
577577
t := int64(stat.Type)
578578
ret, ok := fsTypeMap[t]
579579
if !ok {

disk/disk_netbsd.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ func IOCountersWithContext(_ context.Context, _ ...string) (map[string]IOCounter
104104
}
105105

106106
func UsageWithContext(_ context.Context, path string) (*UsageStat, error) {
107-
stat := Statvfs{}
107+
stat := &Statvfs{}
108108
flag := uint64(1) // ST_WAIT/MNT_WAIT, see sys/fstypes.h
109109

110110
_path, e := unix.BytePtrFromString(path)
@@ -115,7 +115,7 @@ func UsageWithContext(_ context.Context, path string) (*UsageStat, error) {
115115
_, _, err := unix.Syscall(
116116
484, // SYS___statvfs190, see sys/syscall.h
117117
uintptr(unsafe.Pointer(_path)),
118-
uintptr(unsafe.Pointer(&stat)),
118+
uintptr(unsafe.Pointer(stat)),
119119
uintptr(unsafe.Pointer(&flag)),
120120
)
121121
if err != 0 {
@@ -141,7 +141,7 @@ func UsageWithContext(_ context.Context, path string) (*UsageStat, error) {
141141
return ret, nil
142142
}
143143

144-
func getFsType(stat Statvfs) string {
144+
func getFsType(stat *Statvfs) string {
145145
return common.ByteToString(stat.Fstypename[:])
146146
}
147147

disk/disk_openbsd.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ func parseDiskstats(buf []byte) (Diskstats, error) {
124124
}
125125

126126
func UsageWithContext(_ context.Context, path string) (*UsageStat, error) {
127-
stat := unix.Statfs_t{}
128-
err := unix.Statfs(path, &stat)
127+
stat := &unix.Statfs_t{}
128+
err := unix.Statfs(path, stat)
129129
if err != nil {
130130
return nil, err
131131
}
@@ -148,7 +148,7 @@ func UsageWithContext(_ context.Context, path string) (*UsageStat, error) {
148148
return ret, nil
149149
}
150150

151-
func getFsType(stat unix.Statfs_t) string {
151+
func getFsType(stat *unix.Statfs_t) string {
152152
return common.ByteToString(stat.F_fstypename[:])
153153
}
154154

disk/disk_unix.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
)
1212

1313
func UsageWithContext(_ context.Context, path string) (*UsageStat, error) {
14-
stat := unix.Statfs_t{}
15-
err := unix.Statfs(path, &stat)
14+
stat := &unix.Statfs_t{}
15+
err := unix.Statfs(path, stat)
1616
if err != nil {
1717
return nil, err
1818
}

0 commit comments

Comments
 (0)