Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ linters:
- commentedOutCode
- deferInLoop
- hexLiteral
- hugeParam
- tooManyResultsChecker
- unnamedResult
enable-all: true
Expand Down
8 changes: 4 additions & 4 deletions cpu/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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+
Expand All @@ -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)

Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion disk/disk_aix_nocgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
}

Expand Down
2 changes: 1 addition & 1 deletion disk/disk_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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[:])
}

Expand Down
2 changes: 1 addition & 1 deletion disk/disk_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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[:])
}

Expand Down
2 changes: 1 addition & 1 deletion disk/disk_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions disk/disk_netbsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand All @@ -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[:])
}

Expand Down
6 changes: 3 additions & 3 deletions disk/disk_openbsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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[:])
}

Expand Down
4 changes: 2 additions & 2 deletions disk/disk_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down