Skip to content

Commit

Permalink
Minor cleanups motivated by staticcheck warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
tbarker25 committed Aug 19, 2021
1 parent 5ce887d commit bc46619
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
7 changes: 2 additions & 5 deletions process/process_linux.go
Expand Up @@ -351,7 +351,7 @@ func (p *Process) PageFaultsWithContext(ctx context.Context) (*PageFaultsStat, e
func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) {
pids, err := common.CallPgrepWithContext(ctx, invoke, p.Pid)
if err != nil {
if pids == nil || len(pids) == 0 {
if len(pids) == 0 {
return nil, ErrorNoChildren
}
return nil, err
Expand Down Expand Up @@ -705,10 +705,7 @@ func (p *Process) fillFromCmdlineWithContext(ctx context.Context) (string, error
return "", err
}
ret := strings.FieldsFunc(string(cmdline), func(r rune) bool {
if r == '\u0000' {
return true
}
return false
return r == '\u0000'
})

return strings.Join(ret, " "), nil
Expand Down
4 changes: 2 additions & 2 deletions process/process_test.go
Expand Up @@ -418,14 +418,14 @@ func Test_Process_Exe(t *testing.T) {

func Test_Process_CpuPercent(t *testing.T) {
p := testGetProcess()
percent, err := p.Percent(0)
_, err := p.Percent(0)
skipIfNotImplementedErr(t, err)
if err != nil {
t.Errorf("error %v", err)
}
duration := time.Duration(1000) * time.Microsecond
time.Sleep(duration)
percent, err = p.Percent(0)
percent, err := p.Percent(0)
if err != nil {
t.Errorf("error %v", err)
}
Expand Down
7 changes: 2 additions & 5 deletions v3/process/process_linux.go
Expand Up @@ -351,7 +351,7 @@ func (p *Process) PageFaultsWithContext(ctx context.Context) (*PageFaultsStat, e
func (p *Process) ChildrenWithContext(ctx context.Context) ([]*Process, error) {
pids, err := common.CallPgrepWithContext(ctx, invoke, p.Pid)
if err != nil {
if pids == nil || len(pids) == 0 {
if len(pids) == 0 {
return nil, ErrorNoChildren
}
return nil, err
Expand Down Expand Up @@ -678,10 +678,7 @@ func (p *Process) fillFromCmdlineWithContext(ctx context.Context) (string, error
return "", err
}
ret := strings.FieldsFunc(string(cmdline), func(r rune) bool {
if r == '\u0000' {
return true
}
return false
return r == '\u0000'
})

return strings.Join(ret, " "), nil
Expand Down
4 changes: 2 additions & 2 deletions v3/process/process_test.go
Expand Up @@ -420,14 +420,14 @@ func Test_Process_Exe(t *testing.T) {

func Test_Process_CpuPercent(t *testing.T) {
p := testGetProcess()
percent, err := p.Percent(0)
_, err := p.Percent(0)
skipIfNotImplementedErr(t, err)
if err != nil {
t.Errorf("error %v", err)
}
duration := time.Duration(1000) * time.Microsecond
time.Sleep(duration)
percent, err = p.Percent(0)
percent, err := p.Percent(0)
if err != nil {
t.Errorf("error %v", err)
}
Expand Down

0 comments on commit bc46619

Please sign in to comment.