diff --git a/cmd/lxc-to-incus/config.go b/cmd/lxc-to-incus/config.go index 73d0c0671d..7156d29d27 100644 --- a/cmd/lxc-to-incus/config.go +++ b/cmd/lxc-to-incus/config.go @@ -9,6 +9,7 @@ import ( "strings" internalUtil "github.com/lxc/incus/v7/internal/util" + "github.com/lxc/incus/v7/shared/logger" "github.com/lxc/incus/v7/shared/util" ) @@ -130,7 +131,7 @@ func parseConfig(path string) ([]string, error) { return nil, err } - defer func() { _ = file.Close() }() + defer logger.WarnOnError(file.Close, "Failed to close file") var config []string diff --git a/cmd/lxc-to-incus/main_netcat.go b/cmd/lxc-to-incus/main_netcat.go index ca4771334f..1f049937a1 100644 --- a/cmd/lxc-to-incus/main_netcat.go +++ b/cmd/lxc-to-incus/main_netcat.go @@ -9,6 +9,7 @@ import ( "github.com/spf13/cobra" "github.com/lxc/incus/v7/internal/eagain" + "github.com/lxc/incus/v7/shared/logger" "github.com/lxc/incus/v7/shared/util" ) @@ -56,7 +57,7 @@ func (c *cmdNetcat) run(cmd *cobra.Command, args []string) error { wg.Add(1) go func() { - defer func() { _ = conn.Close() }() + defer logger.WarnOnError(conn.Close, "Failed to close connection") defer wg.Done() _, _ = util.SafeCopy(eagain.Writer{Writer: os.Stdout}, eagain.Reader{Reader: conn}) diff --git a/cmd/lxc-to-incus/transfer.go b/cmd/lxc-to-incus/transfer.go index c339c32efc..5e8f30dd62 100644 --- a/cmd/lxc-to-incus/transfer.go +++ b/cmd/lxc-to-incus/transfer.go @@ -13,6 +13,7 @@ import ( "github.com/lxc/incus/v7/internal/linux" "github.com/lxc/incus/v7/internal/migration" + "github.com/lxc/incus/v7/shared/logger" "github.com/lxc/incus/v7/shared/ws" ) @@ -24,7 +25,7 @@ func rsyncSend(conn *websocket.Conn, path string, rsyncArgs string) error { } if dataSocket != nil { - defer func() { _ = dataSocket.Close() }() + defer logger.WarnOnError(dataSocket.Close, "Failed to close connection") } readDone, writeDone := ws.Mirror(conn, dataSocket)