From fe74bba2bd8b3bed84f456313275500fca90f441 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Thu, 15 Aug 2019 11:56:44 -0700 Subject: Don't dereference errors passed to panic() These errors are always pointers; there's no sense in dereferencing them in the panic call. Changed one false positive for clarity. PiperOrigin-RevId: 263611579 --- pkg/tcpip/transport/icmp/endpoint_state.go | 4 ++-- pkg/tcpip/transport/raw/endpoint_state.go | 4 ++-- pkg/tcpip/transport/udp/endpoint_state.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'pkg/tcpip') diff --git a/pkg/tcpip/transport/icmp/endpoint_state.go b/pkg/tcpip/transport/icmp/endpoint_state.go index c5690174e..c587b96b6 100644 --- a/pkg/tcpip/transport/icmp/endpoint_state.go +++ b/pkg/tcpip/transport/icmp/endpoint_state.go @@ -78,7 +78,7 @@ func (e *endpoint) Resume(s *stack.Stack) { if e.state == stateConnected { e.route, err = e.stack.FindRoute(e.regNICID, e.bindAddr, e.id.RemoteAddress, e.netProto, false /* multicastLoop */) if err != nil { - panic(*err) + panic(err) } e.id.LocalAddress = e.route.LocalAddress @@ -90,6 +90,6 @@ func (e *endpoint) Resume(s *stack.Stack) { e.id, err = e.registerWithStack(e.regNICID, []tcpip.NetworkProtocolNumber{e.netProto}, e.id) if err != nil { - panic(*err) + panic(err) } } diff --git a/pkg/tcpip/transport/raw/endpoint_state.go b/pkg/tcpip/transport/raw/endpoint_state.go index a3d6f4580..168953dec 100644 --- a/pkg/tcpip/transport/raw/endpoint_state.go +++ b/pkg/tcpip/transport/raw/endpoint_state.go @@ -75,7 +75,7 @@ func (ep *endpoint) Resume(s *stack.Stack) { var err *tcpip.Error ep.route, err = ep.stack.FindRoute(ep.registeredNIC, ep.boundAddr, ep.route.RemoteAddress, ep.netProto, false) if err != nil { - panic(*err) + panic(err) } } @@ -87,6 +87,6 @@ func (ep *endpoint) Resume(s *stack.Stack) { } if err := ep.stack.RegisterRawTransportEndpoint(ep.registeredNIC, ep.netProto, ep.transProto, ep); err != nil { - panic(*err) + panic(err) } } diff --git a/pkg/tcpip/transport/udp/endpoint_state.go b/pkg/tcpip/transport/udp/endpoint_state.go index bc821a96f..4a3c30115 100644 --- a/pkg/tcpip/transport/udp/endpoint_state.go +++ b/pkg/tcpip/transport/udp/endpoint_state.go @@ -95,7 +95,7 @@ func (e *endpoint) Resume(s *stack.Stack) { if e.state == stateConnected { e.route, err = e.stack.FindRoute(e.regNICID, e.id.LocalAddress, e.id.RemoteAddress, netProto, e.multicastLoop) if err != nil { - panic(*err) + panic(err) } } else if len(e.id.LocalAddress) != 0 { // stateBound if e.stack.CheckLocalAddress(e.regNICID, netProto, e.id.LocalAddress) == 0 { @@ -110,6 +110,6 @@ func (e *endpoint) Resume(s *stack.Stack) { e.id.LocalPort = 0 e.id, err = e.registerWithStack(e.regNICID, e.effectiveNetProtos, id) if err != nil { - panic(*err) + panic(err) } } -- cgit v1.2.3