From cb58269c3336be83af0826fa6b880092e9ac4d07 Mon Sep 17 00:00:00 2001 From: CFC4N Date: Fri, 19 Aug 2022 21:27:55 +0800 Subject: [PATCH] pkg/util/ebpf : fix error value. Signed-off-by: CFC4N --- pkg/util/ebpf/bpf_androidgki.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/pkg/util/ebpf/bpf_androidgki.go b/pkg/util/ebpf/bpf_androidgki.go index a91503645..cfc1dca01 100644 --- a/pkg/util/ebpf/bpf_androidgki.go +++ b/pkg/util/ebpf/bpf_androidgki.go @@ -49,18 +49,19 @@ func getAndroidConfig(filename string) (map[string]string, error) { if i != 2 { return KernelConfig, fmt.Errorf("read %d bytes, expected 2", i) } + + var s *bufio.Scanner _, err = f.Seek(0, 0) if err != nil { return KernelConfig, err } - var s *bufio.Scanner - // big-endian magic number for gzip is 0x1f8b - // little-endian magic number for gzip is 0x8b1f - if (magic[0] == 0x1f && magic[1] == 0x8b) || (magic[0] == 0x8b && magic[1] == 0x1f) { + var reader *gzip.Reader + //magic number for gzip is 0x1f8b + if magic[0] == 0x1f && magic[1] == 0x8b { // gzip file - reader, e := gzip.NewReader(f) - if e != nil { + reader, err = gzip.NewReader(f) + if err != nil { return KernelConfig, err } s = bufio.NewScanner(reader)