Quellcode durchsuchen

Merge remote-tracking branch 'dominikh/minor-code-touchups'

Solomon Hykes vor 12 Jahren
Ursprung
Commit
586a79cca0
5 geänderte Dateien mit 10 neuen und 12 gelöschten Zeilen
  1. 3 4
      commands.go
  2. 1 1
      container.go
  3. 1 1
      network.go
  4. 4 5
      runtime_test.go
  5. 1 1
      utils.go

+ 3 - 4
commands.go

@@ -99,7 +99,7 @@ func (srv *Server) CmdLogin(stdin io.ReadCloser, stdout io.Writer, args ...strin
 			}
 			if err != nil {
 				if err != io.EOF {
-					fmt.Fprint(stdout, "Read error: %v\n", err)
+					fmt.Fprintf(stdout, "Read error: %v\n", err)
 				}
 				break
 			}
@@ -512,10 +512,9 @@ func (srv *Server) CmdPush(stdin io.ReadCloser, stdout io.Writer, args ...string
 				return err
 			}
 			return nil
-		} else {
-			return err
 		}
-		return nil
+
+		return err
 	}
 	err = srv.runtime.graph.PushImage(stdout, img, srv.runtime.authConfig)
 	if err != nil {

+ 1 - 1
container.go

@@ -652,7 +652,7 @@ func (container *Container) WaitTimeout(timeout time.Duration) error {
 	case <-done:
 		return nil
 	}
-	return nil
+	panic("unreachable")
 }
 
 func (container *Container) EnsureMounted() error {

+ 1 - 1
network.go

@@ -187,7 +187,7 @@ func (alloc *PortAllocator) Release(port int) error {
 	default:
 		return errors.New("Too many ports have been released")
 	}
-	return nil
+	panic("unreachable")
 }
 
 func newPortAllocator(start, end int) (*PortAllocator, error) {

+ 4 - 5
runtime_test.go

@@ -22,10 +22,10 @@ func nuke(runtime *Runtime) error {
 	var wg sync.WaitGroup
 	for _, container := range runtime.List() {
 		wg.Add(1)
-		go func() {
-			container.Kill()
-			wg.Add(-1)
-		}()
+		go func(c *Container) {
+			c.Kill()
+			wg.Done()
+		}(container)
 	}
 	wg.Wait()
 	return os.RemoveAll(runtime.root)
@@ -91,7 +91,6 @@ func newTestRuntime() (*Runtime, error) {
 		return nil, err
 	}
 	if err := CopyDirectory(unitTestStoreBase, root); err != nil {
-		panic(err)
 		return nil, err
 	}
 

+ 1 - 1
utils.go

@@ -202,7 +202,7 @@ func (r *bufReader) Read(p []byte) (n int, err error) {
 		}
 		r.wait.Wait()
 	}
-	return
+	panic("unreachable")
 }
 
 func (r *bufReader) Close() error {