From ffe885ec0e8a06c1614949bf383f6d1532f02c1d Mon Sep 17 00:00:00 2001 From: Kohei Tsuruta Date: Wed, 16 Jul 2014 23:09:17 +0900 Subject: [PATCH] Change switch to if so that the break statements correctly breaks loop Docker-DCO-1.1-Signed-off-by: Kohei Tsuruta (github: coheyxyz) --- daemon/networkdriver/bridge/driver.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/daemon/networkdriver/bridge/driver.go b/daemon/networkdriver/bridge/driver.go index 9cffe29f3d..beb01243f9 100644 --- a/daemon/networkdriver/bridge/driver.go +++ b/daemon/networkdriver/bridge/driver.go @@ -415,8 +415,7 @@ func AllocatePort(job *engine.Job) engine.Status { break } - switch allocerr := err.(type) { - case portallocator.ErrPortAlreadyAllocated: + if allocerr, ok := err.(portallocator.ErrPortAlreadyAllocated); ok { // There is no point in immediately retrying to map an explicitly // chosen port. if hostPort != 0 { @@ -426,7 +425,7 @@ func AllocatePort(job *engine.Job) engine.Status { // Automatically chosen 'free' port failed to bind: move on the next. job.Logf("Failed to bind %s for container address %s. Trying another port.", allocerr.IPPort(), container.String()) - default: + } else { // some other error during mapping job.Logf("Received an unexpected error during port allocation: %s", err.Error()) break