From f5c833fe35ce00226fbc179f657da6759123c03c Mon Sep 17 00:00:00 2001 From: Matthieu MOREL Date: Sun, 27 Jul 2025 11:09:32 +0200 Subject: [PATCH] chore: enable hugeParam from go-critic Signed-off-by: Matthieu MOREL --- .golangci.yml | 1 - cpu/cpu.go | 8 ++++---- disk/disk_aix_nocgo.go | 2 +- disk/disk_darwin.go | 2 +- disk/disk_freebsd.go | 2 +- disk/disk_linux.go | 2 +- disk/disk_netbsd.go | 6 +++--- disk/disk_openbsd.go | 6 +++--- disk/disk_unix.go | 4 ++-- 9 files changed, 16 insertions(+), 17 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 30c3db394a..a5fa0a478f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -47,7 +47,6 @@ linters: - commentedOutCode - deferInLoop - hexLiteral - - hugeParam - tooManyResultsChecker - unnamedResult enable-all: true diff --git a/cpu/cpu.go b/cpu/cpu.go index 9bc3dfb51a..aa7add308b 100644 --- a/cpu/cpu.go +++ b/cpu/cpu.go @@ -91,7 +91,7 @@ func (c TimesStat) String() string { // Deprecated: Total returns the total number of seconds in a CPUTimesStat // Please do not use this internal function. -func (c TimesStat) Total() float64 { +func (c *TimesStat) Total() float64 { total := c.User + c.System + c.Idle + c.Nice + c.Iowait + c.Irq + c.Softirq + c.Steal + c.Guest + c.GuestNice @@ -103,7 +103,7 @@ func (c InfoStat) String() string { return string(s) } -func getAllBusy(t TimesStat) (float64, float64) { +func getAllBusy(t *TimesStat) (float64, float64) { tot := t.Total() if runtime.GOOS == "linux" { tot -= t.Guest // Linux 2.6.24+ @@ -115,7 +115,7 @@ func getAllBusy(t TimesStat) (float64, float64) { return tot, busy } -func calculateBusy(t1, t2 TimesStat) float64 { +func calculateBusy(t1, t2 *TimesStat) float64 { t1All, t1Busy := getAllBusy(t1) t2All, t2Busy := getAllBusy(t2) @@ -139,7 +139,7 @@ func calculateAllBusy(t1, t2 []TimesStat) ([]float64, error) { ret := make([]float64, len(t1)) for i, t := range t2 { - ret[i] = calculateBusy(t1[i], t) + ret[i] = calculateBusy(&t1[i], &t) } return ret, nil } diff --git a/disk/disk_aix_nocgo.go b/disk/disk_aix_nocgo.go index 75b651ab23..e54e588975 100644 --- a/disk/disk_aix_nocgo.go +++ b/disk/disk_aix_nocgo.go @@ -80,7 +80,7 @@ func PartitionsWithContext(ctx context.Context, _ bool) ([]PartitionStat, error) return ret, nil } -func getFsType(stat unix.Statfs_t) string { +func getFsType(stat *unix.Statfs_t) string { return FSType[int(stat.Vfstype)] } diff --git a/disk/disk_darwin.go b/disk/disk_darwin.go index 975eb10e64..ce3dbb286a 100644 --- a/disk/disk_darwin.go +++ b/disk/disk_darwin.go @@ -87,7 +87,7 @@ func PartitionsWithContext(_ context.Context, _ bool) ([]PartitionStat, error) { return ret, nil } -func getFsType(stat unix.Statfs_t) string { +func getFsType(stat *unix.Statfs_t) string { return common.ByteToString(stat.Fstypename[:]) } diff --git a/disk/disk_freebsd.go b/disk/disk_freebsd.go index 27b7b5d22b..a5ad207f46 100644 --- a/disk/disk_freebsd.go +++ b/disk/disk_freebsd.go @@ -161,7 +161,7 @@ func parsedevstat(buf []byte) (devstat, error) { return ds, nil } -func getFsType(stat unix.Statfs_t) string { +func getFsType(stat *unix.Statfs_t) string { return common.ByteToString(stat.Fstypename[:]) } diff --git a/disk/disk_linux.go b/disk/disk_linux.go index 8c4803338c..ebcf00d161 100644 --- a/disk/disk_linux.go +++ b/disk/disk_linux.go @@ -574,7 +574,7 @@ func LabelWithContext(ctx context.Context, name string) (string, error) { return label, nil } -func getFsType(stat unix.Statfs_t) string { +func getFsType(stat *unix.Statfs_t) string { t := int64(stat.Type) ret, ok := fsTypeMap[t] if !ok { diff --git a/disk/disk_netbsd.go b/disk/disk_netbsd.go index 1859405f6b..24f5007764 100644 --- a/disk/disk_netbsd.go +++ b/disk/disk_netbsd.go @@ -104,7 +104,7 @@ func IOCountersWithContext(_ context.Context, _ ...string) (map[string]IOCounter } func UsageWithContext(_ context.Context, path string) (*UsageStat, error) { - stat := Statvfs{} + stat := &Statvfs{} flag := uint64(1) // ST_WAIT/MNT_WAIT, see sys/fstypes.h _path, e := unix.BytePtrFromString(path) @@ -115,7 +115,7 @@ func UsageWithContext(_ context.Context, path string) (*UsageStat, error) { _, _, err := unix.Syscall( 484, // SYS___statvfs190, see sys/syscall.h uintptr(unsafe.Pointer(_path)), - uintptr(unsafe.Pointer(&stat)), + uintptr(unsafe.Pointer(stat)), uintptr(unsafe.Pointer(&flag)), ) if err != 0 { @@ -141,7 +141,7 @@ func UsageWithContext(_ context.Context, path string) (*UsageStat, error) { return ret, nil } -func getFsType(stat Statvfs) string { +func getFsType(stat *Statvfs) string { return common.ByteToString(stat.Fstypename[:]) } diff --git a/disk/disk_openbsd.go b/disk/disk_openbsd.go index 1839aa5f42..86c19d9516 100644 --- a/disk/disk_openbsd.go +++ b/disk/disk_openbsd.go @@ -122,8 +122,8 @@ func parseDiskstats(buf []byte) (Diskstats, error) { } func UsageWithContext(_ context.Context, path string) (*UsageStat, error) { - stat := unix.Statfs_t{} - err := unix.Statfs(path, &stat) + stat := &unix.Statfs_t{} + err := unix.Statfs(path, stat) if err != nil { return nil, err } @@ -146,7 +146,7 @@ func UsageWithContext(_ context.Context, path string) (*UsageStat, error) { return ret, nil } -func getFsType(stat unix.Statfs_t) string { +func getFsType(stat *unix.Statfs_t) string { return common.ByteToString(stat.F_fstypename[:]) } diff --git a/disk/disk_unix.go b/disk/disk_unix.go index 482372da2b..770c2ea5a6 100644 --- a/disk/disk_unix.go +++ b/disk/disk_unix.go @@ -11,8 +11,8 @@ import ( ) func UsageWithContext(_ context.Context, path string) (*UsageStat, error) { - stat := unix.Statfs_t{} - err := unix.Statfs(path, &stat) + stat := &unix.Statfs_t{} + err := unix.Statfs(path, stat) if err != nil { return nil, err }