Code refactor: remove a function scope variable err for psi stats#3938
Code refactor: remove a function scope variable err for psi stats#3938lifubang wants to merge 1 commit intoopencontainers:mainfrom
Conversation
Signed-off-by: lifubang <lifubang@acmcoder.com>
|
ci lint error: The |
| } | ||
|
|
||
| func statCpuPressure(dirPath string, stats *cgroups.Stats) error { | ||
| const file = "cpu.pressure" |
There was a problem hiding this comment.
I would pass "cpu.pressure" directly, without adding an intermediary const. The const would make sense if we use it more than once, or if the value is complicated/long -- neither is the case here.
|
I'm neutral on this.
Left a nit about using consts for file names, but overall LGTM |
|
Re: linter, I think we can start naming things better ( @thaJeztah WDYT? |
| func statIoPressure(dirPath string, stats *cgroups.Stats) error { | ||
| const file = "io.pressure" | ||
| var err error | ||
|
|
||
| stats.BlkioStats.PSI, err = statPSI(dirPath, file) | ||
| return err | ||
| } |
There was a problem hiding this comment.
I'd rewrite this one to
func statIoPressure(dirPath string, stats *cgroups.Stats) (Err error) {
stats.BlkioStats.PSI, Err = statPSI(dirPath, "io.pressure")
return
}There was a problem hiding this comment.
but with this rewrite, it doesn't make much sense to have it as a separate function, right?
kolyshkin
left a comment
There was a problem hiding this comment.
I don't think this makes the code much better than it is.
Address #3900 (comment)
I think it's unnecessary to add a function scope variable suddenly. We should keep the code style like other cgroup stats.