From 389cfd136d450f59c81ce310ce8af6cabca7b580 Mon Sep 17 00:00:00 2001 From: Flavio Crisciani Date: Wed, 20 Sep 2017 08:57:02 -0700 Subject: [PATCH] Fix lint issues The package updated and now shows new warnings that had to be corrected to let the CI pass Signed-off-by: Flavio Crisciani (cherry picked from commit 9e5748ad7dc65318889693365a53492be94b1521) Signed-off-by: Sebastiaan van Stijn --- cmd/dnet/dnet.go | 6 +----- drivers/bridge/bridge.go | 6 +----- drivers/bridge/setup_ip_tables.go | 11 ++--------- drivers/overlay/ov_endpoint.go | 11 ++--------- drivers/solaris/overlay/ov_endpoint.go | 11 ++--------- endpoint_info.go | 6 +----- iptables/iptables.go | 11 ++--------- sandbox_dns_unix.go | 6 +----- 8 files changed, 12 insertions(+), 56 deletions(-) diff --git a/cmd/dnet/dnet.go b/cmd/dnet/dnet.go index 8086137347..9b263cd697 100644 --- a/cmd/dnet/dnet.go +++ b/cmd/dnet/dnet.go @@ -419,11 +419,7 @@ func startTestDriver() error { return err } - if err := ioutil.WriteFile("/etc/docker/plugins/test.spec", []byte(server.URL), 0644); err != nil { - return err - } - - return nil + return ioutil.WriteFile("/etc/docker/plugins/test.spec", []byte(server.URL), 0644) } func newDnetConnection(val string) (*dnetConnection, error) { diff --git a/drivers/bridge/bridge.go b/drivers/bridge/bridge.go index 64a2743dcf..1742c8df31 100644 --- a/drivers/bridge/bridge.go +++ b/drivers/bridge/bridge.go @@ -763,11 +763,7 @@ func (d *driver) createNetwork(config *networkConfiguration) error { // Apply the prepared list of steps, and abort at the first error. bridgeSetup.queueStep(setupDeviceUp) - if err = bridgeSetup.apply(); err != nil { - return err - } - - return nil + return bridgeSetup.apply() } func (d *driver) DeleteNetwork(nid string) error { diff --git a/drivers/bridge/setup_ip_tables.go b/drivers/bridge/setup_ip_tables.go index f01b08dea0..da654449d2 100644 --- a/drivers/bridge/setup_ip_tables.go +++ b/drivers/bridge/setup_ip_tables.go @@ -169,11 +169,7 @@ func setupIPTablesInternal(bridgeIface string, addr net.Addr, icc, ipmasq, hairp } // Set Accept on all non-intercontainer outgoing packets. - if err := programChainRule(outRule, "ACCEPT NON_ICC OUTGOING", enable); err != nil { - return err - } - - return nil + return programChainRule(outRule, "ACCEPT NON_ICC OUTGOING", enable) } func programChainRule(rule iptRule, ruleDescr string, insert bool) error { @@ -304,10 +300,7 @@ func setupInternalNetworkRules(bridgeIface string, addr net.Addr, icc, insert bo return err } // Set Inter Container Communication. - if err := setIcc(bridgeIface, icc, insert); err != nil { - return err - } - return nil + return setIcc(bridgeIface, icc, insert) } func clearEndpointConnections(nlh *netlink.Handle, ep *bridgeEndpoint) { diff --git a/drivers/overlay/ov_endpoint.go b/drivers/overlay/ov_endpoint.go index d0e63f6b7e..bb08de465c 100644 --- a/drivers/overlay/ov_endpoint.go +++ b/drivers/overlay/ov_endpoint.go @@ -144,11 +144,7 @@ func (d *driver) deleteEndpointFromStore(e *endpoint) error { return fmt.Errorf("overlay local store not initialized, ep not deleted") } - if err := d.localStore.DeleteObjectAtomic(e); err != nil { - return err - } - - return nil + return d.localStore.DeleteObjectAtomic(e) } func (d *driver) writeEndpointToStore(e *endpoint) error { @@ -156,10 +152,7 @@ func (d *driver) writeEndpointToStore(e *endpoint) error { return fmt.Errorf("overlay local store not initialized, ep not added") } - if err := d.localStore.PutObjectAtomic(e); err != nil { - return err - } - return nil + return d.localStore.PutObjectAtomic(e) } func (ep *endpoint) DataScope() string { diff --git a/drivers/solaris/overlay/ov_endpoint.go b/drivers/solaris/overlay/ov_endpoint.go index 21b33ffe85..9df7a5874b 100644 --- a/drivers/solaris/overlay/ov_endpoint.go +++ b/drivers/solaris/overlay/ov_endpoint.go @@ -134,11 +134,7 @@ func (d *driver) deleteEndpointFromStore(e *endpoint) error { return fmt.Errorf("overlay local store not initialized, ep not deleted") } - if err := d.localStore.DeleteObjectAtomic(e); err != nil { - return err - } - - return nil + return d.localStore.DeleteObjectAtomic(e) } func (d *driver) writeEndpointToStore(e *endpoint) error { @@ -146,10 +142,7 @@ func (d *driver) writeEndpointToStore(e *endpoint) error { return fmt.Errorf("overlay local store not initialized, ep not added") } - if err := d.localStore.PutObjectAtomic(e); err != nil { - return err - } - return nil + return d.localStore.PutObjectAtomic(e) } func (ep *endpoint) DataScope() string { diff --git a/endpoint_info.go b/endpoint_info.go index 47bff432cb..d99a009b94 100644 --- a/endpoint_info.go +++ b/endpoint_info.go @@ -199,11 +199,7 @@ func (ep *endpoint) Info() EndpointInfo { return ep } - if epi := sb.getEndpoint(ep.ID()); epi != nil { - return epi - } - - return nil + return sb.getEndpoint(ep.ID()) } func (ep *endpoint) Iface() InterfaceInfo { diff --git a/iptables/iptables.go b/iptables/iptables.go index ecce0d3b2a..3e120059de 100644 --- a/iptables/iptables.go +++ b/iptables/iptables.go @@ -276,11 +276,7 @@ func (c *ChainInfo) Forward(action Action, ip net.IP, port int, proto, destAddr "--dport", strconv.Itoa(destPort), "-j", "MASQUERADE", } - if err := ProgramRule(Nat, "POSTROUTING", action, args); err != nil { - return err - } - - return nil + return ProgramRule(Nat, "POSTROUTING", action, args) } // Link adds reciprocal ACCEPT rule for two supplied IP addresses. @@ -301,10 +297,7 @@ func (c *ChainInfo) Link(action Action, ip1, ip2 net.IP, port int, proto string, // reverse args[7], args[9] = args[9], args[7] args[10] = "--sport" - if err := ProgramRule(Filter, c.Name, action, args); err != nil { - return err - } - return nil + return ProgramRule(Filter, c.Name, action, args) } // ProgramRule adds the rule specified by args only if the diff --git a/sandbox_dns_unix.go b/sandbox_dns_unix.go index f18f0b3ee6..0615b6f402 100644 --- a/sandbox_dns_unix.go +++ b/sandbox_dns_unix.go @@ -67,11 +67,7 @@ func (sb *sandbox) setupResolutionFiles() error { return err } - if err := sb.setupDNS(); err != nil { - return err - } - - return nil + return sb.setupDNS() } func (sb *sandbox) buildHostsFile() error {