Skip to content

Commit

Permalink
[Linux] Use len check instead of nil check for memory
Browse files Browse the repository at this point in the history
  • Loading branch information
Sploder12 committed Feb 3, 2025
1 parent 4597dbf commit 871dfc1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/collector/sysinfo/hardware/hardware_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (s Collector) collectMemory() (info memory, err error) {
}

m := meminfoRegex.FindStringSubmatch(l)
if m == nil {
if len(m) != 4 {
s.opts.log.Warn("meminfo contains invalid line", "line", l, "linenum", i)
continue
}
Expand Down Expand Up @@ -336,7 +336,7 @@ func (s Collector) collectScreens() (info []screen, err error) {
for i, header := range headers {
v := screenConfigRegex.FindStringSubmatch(screens[i+1])

if len(v) < 3 {
if len(v) < 3 || len(header) != 5 {
s.opts.log.Warn("xrandr screen info malformed", "screen", header[1])
continue
}
Expand Down

0 comments on commit 871dfc1

Please sign in to comment.