From f30e4faad64900e188cf67f5a79c594e1781f766 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 23 Jul 2024 18:32:34 -0700 Subject: [PATCH] Load: don't ignore Sscanf errors This fixes errcheck linter warnings: > capability_linux.go:311:14: Error return value of `fmt.Sscanf` is not checked (errcheck) > fmt.Sscanf(line[4:], "nd: %08x%08x", &c.bounds[1], &c.bounds[0]) > ^ > capability_linux.go:315:14: Error return value of `fmt.Sscanf` is not checked (errcheck) > fmt.Sscanf(line[4:], "mb: %08x%08x", &c.ambient[1], &c.ambient[0]) > ^ Signed-off-by: Kir Kolyshkin --- capability_linux.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/capability_linux.go b/capability_linux.go index 60b283e..baee24d 100644 --- a/capability_linux.go +++ b/capability_linux.go @@ -304,11 +304,17 @@ func (c *capsV3) Load() (err error) { break } if strings.HasPrefix(line, "CapB") { - fmt.Sscanf(line[4:], "nd: %08x%08x", &c.bounds[1], &c.bounds[0]) + _, err = fmt.Sscanf(line[4:], "nd: %08x%08x", &c.bounds[1], &c.bounds[0]) + if err != nil { + break + } continue } if strings.HasPrefix(line, "CapA") { - fmt.Sscanf(line[4:], "mb: %08x%08x", &c.ambient[1], &c.ambient[0]) + _, err = fmt.Sscanf(line[4:], "mb: %08x%08x", &c.ambient[1], &c.ambient[0]) + if err != nil { + break + } continue } }