From d91ae65280c789307ec67fff7e2d268afe3aeba7 Mon Sep 17 00:00:00 2001 From: Zhang Wei Date: Tue, 19 May 2015 10:54:04 +0800 Subject: [PATCH] clean some redundant else clauses Signed-off-by: Zhang Wei --- api/client/help.go | 5 ++--- daemon/networkdriver/bridge/driver.go | 12 ++++++------ pkg/units/duration.go | 3 +-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/api/client/help.go b/api/client/help.go index 5dee9ba8a1..8e1dc852b7 100644 --- a/api/client/help.go +++ b/api/client/help.go @@ -23,10 +23,9 @@ func (cli *DockerCli) CmdHelp(args ...string) error { method, exists := cli.getMethod(args[0]) if !exists { return fmt.Errorf("docker: '%s' is not a docker command. See 'docker --help'.", args[0]) - } else { - method("--help") - return nil } + method("--help") + return nil } flag.Usage() diff --git a/daemon/networkdriver/bridge/driver.go b/daemon/networkdriver/bridge/driver.go index 1be1a7817f..3449f4a1ef 100644 --- a/daemon/networkdriver/bridge/driver.go +++ b/daemon/networkdriver/bridge/driver.go @@ -307,11 +307,11 @@ func InitDriver(config *Config) error { } } - if gateway, err := requestDefaultGateway(config.DefaultGatewayIPv4, bridgeIPv4Network); err != nil { + gateway, err := requestDefaultGateway(config.DefaultGatewayIPv4, bridgeIPv4Network) + if err != nil { return err - } else { - gatewayIPv4 = gateway } + gatewayIPv4 = gateway if config.FixedCIDRv6 != "" { _, subnet, err := net.ParseCIDR(config.FixedCIDRv6) @@ -325,11 +325,11 @@ func InitDriver(config *Config) error { } globalIPv6Network = subnet - if gateway, err := requestDefaultGateway(config.DefaultGatewayIPv6, globalIPv6Network); err != nil { + gateway, err := requestDefaultGateway(config.DefaultGatewayIPv6, globalIPv6Network) + if err != nil { return err - } else { - gatewayIPv6 = gateway } + gatewayIPv6 = gateway } // Block BridgeIP in IP allocator diff --git a/pkg/units/duration.go b/pkg/units/duration.go index a31f780e3b..44012aafb5 100644 --- a/pkg/units/duration.go +++ b/pkg/units/duration.go @@ -26,7 +26,6 @@ func HumanDuration(d time.Duration) string { return fmt.Sprintf("%d weeks", hours/24/7) } else if hours < 24*365*2 { return fmt.Sprintf("%d months", hours/24/30) - } else { - return fmt.Sprintf("%d years", hours/24/365) } + return fmt.Sprintf("%d years", int(d.Hours())/24/365) }