Skip to content

Commit 5def8b2

Browse files
kolyshkindims
authored andcommitted
container/libcontainer: fix errcheck warning
Fix the following errcheck warning (reported by golangci-lint v1.61.0): container/libcontainer/handler.go:741:13: Error return value of `fmt.Sscanf` is not checked (errcheck) fmt.Sscanf(fs[4], "%X:%X", &rx, &tx) ^ While at it, simplify instantiation of the adjacent variables. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 074df23 commit 5def8b2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

container/libcontainer/handler.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -717,10 +717,7 @@ func scanUDPStats(r io.Reader) (info.UdpStat, error) {
717717
return stats, scanner.Err()
718718
}
719719

720-
listening := uint64(0)
721-
dropped := uint64(0)
722-
rxQueued := uint64(0)
723-
txQueued := uint64(0)
720+
var listening, dropped, rxQueued, txQueued uint64
724721

725722
for scanner.Scan() {
726723
line := scanner.Text()
@@ -733,8 +730,11 @@ func scanUDPStats(r io.Reader) (info.UdpStat, error) {
733730
continue
734731
}
735732

736-
rx, tx := uint64(0), uint64(0)
737-
fmt.Sscanf(fs[4], "%X:%X", &rx, &tx)
733+
var rx, tx uint64
734+
_, err := fmt.Sscanf(fs[4], "%X:%X", &rx, &tx)
735+
if err != nil {
736+
continue
737+
}
738738
rxQueued += rx
739739
txQueued += tx
740740

0 commit comments

Comments
 (0)