From 382bb0fde6dc781e2ae926b8c91d254f43517b45 Mon Sep 17 00:00:00 2001 From: Eng Zer Jun Date: Mon, 18 Sep 2023 23:01:52 +0800 Subject: [PATCH] pkg/proc/internal/ebpf: remove redundant nil check (#3502) From the Go specification: "1. For a nil slice, the number of iterations is 0." [1] Therefore, an additional nil check for before the loop is unnecessary. [1]: https://go.dev/ref/spec#For_range Signed-off-by: Eng Zer Jun --- pkg/proc/internal/ebpf/helpers.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pkg/proc/internal/ebpf/helpers.go b/pkg/proc/internal/ebpf/helpers.go index cddb4af7..3f4fde40 100644 --- a/pkg/proc/internal/ebpf/helpers.go +++ b/pkg/proc/internal/ebpf/helpers.go @@ -71,10 +71,8 @@ func (ctx *EBPFContext) Close() { if ctx.objs != nil { ctx.objs.Close() } - if ctx.links != nil { - for _, l := range ctx.links { - l.Close() - } + for _, l := range ctx.links { + l.Close() } }