From 7b473f60ae0dc5b247e56a09a55e9d2fa1060c9f Mon Sep 17 00:00:00 2001 From: Phi Date: Mon, 30 Oct 2023 09:59:59 +0000 Subject: [PATCH] Handle errors from Close() in CheckUDPBufferSize Added error handling for the Close() method calls in the CheckUDPBufferSize function to satisfy linting rules and improve error logging. --- node/modules/alerts.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/node/modules/alerts.go b/node/modules/alerts.go index 568c39a91..9976c6d0e 100644 --- a/node/modules/alerts.go +++ b/node/modules/alerts.go @@ -48,7 +48,11 @@ func CheckUDPBufferSize(wanted int) func(al *alerting.Alerting) { }) return } - defer conn.Close() + defer func() { + if err := conn.Close(); err != nil { + log.Warnf("Failed to close connection: %s", err) + } + }() udpConn, ok := conn.(*net.UDPConn) if !ok { @@ -68,7 +72,11 @@ func CheckUDPBufferSize(wanted int) func(al *alerting.Alerting) { }) return } - defer file.Close() + defer func() { + if err := file.Close(); err != nil { + log.Warnf("Failed to close file: %s", err) + } + }() size, err := syscall.GetsockoptInt(int(file.Fd()), syscall.SOL_SOCKET, syscall.SO_RCVBUF) if err != nil {