diff --git a/cmd/imagetool/addImagefile.go b/cmd/imagetool/addImagefile.go index 1bc68eec..99c84016 100644 --- a/cmd/imagetool/addImagefile.go +++ b/cmd/imagetool/addImagefile.go @@ -28,7 +28,7 @@ func addImagefile(imageSClient *srpc.Client, name, imageFilename, filterFilename, triggersFilename string) error { imageExists, err := client.CheckImage(imageSClient, name) if err != nil { - return errors.New("error checking for image existance: " + err.Error()) + return errors.New("error checking for image existence: " + err.Error()) } if imageExists { return errors.New("image exists") diff --git a/cmd/imagetool/addImageimage.go b/cmd/imagetool/addImageimage.go index 820f0ad0..6e1581c2 100644 --- a/cmd/imagetool/addImageimage.go +++ b/cmd/imagetool/addImageimage.go @@ -27,7 +27,7 @@ func addImageimage(imageSClient *srpc.Client, name, oldImageName, filterFilename, triggersFilename string) error { imageExists, err := client.CheckImage(imageSClient, name) if err != nil { - return errors.New("error checking for image existance: " + err.Error()) + return errors.New("error checking for image existence: " + err.Error()) } if imageExists { return errors.New("image exists") diff --git a/cmd/imagetool/addImagesub.go b/cmd/imagetool/addImagesub.go index d9b467f6..de2b62e4 100644 --- a/cmd/imagetool/addImagesub.go +++ b/cmd/imagetool/addImagesub.go @@ -33,7 +33,7 @@ func addImagesub(imageSClient *srpc.Client, name, subName, filterFilename, triggersFilename string) error { imageExists, err := client.CheckImage(imageSClient, name) if err != nil { - return errors.New("error checking for image existance: " + err.Error()) + return errors.New("error checking for image existence: " + err.Error()) } if imageExists { return errors.New("image exists") diff --git a/cmd/imagetool/addReplaceImage.go b/cmd/imagetool/addReplaceImage.go index a1805398..b8eab2d2 100644 --- a/cmd/imagetool/addReplaceImage.go +++ b/cmd/imagetool/addReplaceImage.go @@ -39,7 +39,7 @@ func addReplaceImage(imageSClient *srpc.Client, name, baseImageName string, layerImageNames []string) error { imageExists, err := client.CheckImage(imageSClient, name) if err != nil { - return errors.New("error checking for image existance: " + err.Error()) + return errors.New("error checking for image existence: " + err.Error()) } if imageExists { return errors.New("image exists") diff --git a/cmd/imagetool/copyImageSubcommand.go b/cmd/imagetool/copyImageSubcommand.go index ae4effa5..999a9214 100644 --- a/cmd/imagetool/copyImageSubcommand.go +++ b/cmd/imagetool/copyImageSubcommand.go @@ -21,7 +21,7 @@ func copyImageSubcommand(args []string) { func copyImage(imageSClient *srpc.Client, name, oldImageName string) error { imageExists, err := client.CheckImage(imageSClient, name) if err != nil { - return errors.New("error checking for image existance: " + err.Error()) + return errors.New("error checking for image existence: " + err.Error()) } if imageExists { return errors.New("image exists") diff --git a/cmd/installer/configureLocalNetwork.go b/cmd/installer/configureLocalNetwork.go index df58503c..ecf6e8d7 100644 --- a/cmd/installer/configureLocalNetwork.go +++ b/cmd/installer/configureLocalNetwork.go @@ -136,6 +136,9 @@ func getConfiguration(interfaces map[string]net.Interface, } err = json.ReadFromFile(filepath.Join(*tftpDirectory, "config.json"), &machineInfo) + if err != nil { + return nil, err + } return &machineInfo, nil } diff --git a/cmd/installer/configureStorage.go b/cmd/installer/configureStorage.go index 66b14edb..f8ccbb69 100644 --- a/cmd/installer/configureStorage.go +++ b/cmd/installer/configureStorage.go @@ -298,9 +298,8 @@ func installRoot(device string, fileSystem *filesystem.FileSystem, if err != nil { return err } - err = util.MakeBootable(fileSystem, device, "rootfs", *mountPoint, "", true, - logger) - return nil + return util.MakeBootable(fileSystem, device, "rootfs", *mountPoint, "", + true, logger) } func installTmpRoot(fileSystem *filesystem.FileSystem, diff --git a/cmd/subd/main.go b/cmd/subd/main.go index 46e706cf..b97927a4 100644 --- a/cmd/subd/main.go +++ b/cmd/subd/main.go @@ -389,9 +389,9 @@ func main() { os.Exit(1) } fsh.Update(nil) - sighupChannel := make(chan os.Signal) + sighupChannel := make(chan os.Signal, 1) signal.Notify(sighupChannel, syscall.SIGHUP) - sigtermChannel := make(chan os.Signal) + sigtermChannel := make(chan os.Signal, 1) signal.Notify(sigtermChannel, syscall.SIGTERM, syscall.SIGINT) writePidfile() for iter := 0; true; { @@ -419,7 +419,7 @@ func main() { iter++ runtime.GC() // An opportune time to take out the garbage. if *showStats { - fmt.Print(fsh) + fmt.Print(&fsh) // Use pointer to silence go vet. fmt.Print(fsh.FileSystem()) memstats.WriteMemoryStats(os.Stdout) fmt.Println() diff --git a/cmd/subd/vCpu.go b/cmd/subd/vCpu.go index 99316b52..788ae364 100644 --- a/cmd/subd/vCpu.go +++ b/cmd/subd/vCpu.go @@ -64,9 +64,6 @@ func adjustVcpuLimit(limit *uint, logger log.Logger) { vCpuCreditRate, err := getAwsVcpuCreditRate() if err == nil && vCpuCreditRate > 0 { newLimit := initialLimit * vCpuCreditRate / 60 / uint(runtime.NumCPU()) - if newLimit < 0 { - newLimit = 1 - } logger.Printf("Adjusting default CPU limit to: %d%%\n", newLimit) *limit = newLimit } diff --git a/cmd/vm-control/importVirshVm.go b/cmd/vm-control/importVirshVm.go index f3b11896..b6e0d04c 100644 --- a/cmd/vm-control/importVirshVm.go +++ b/cmd/vm-control/importVirshVm.go @@ -86,6 +86,9 @@ func ensureDomainIsStopped(domainName string) error { } response, err := askForInputChoice("Cannot import running VM", []string{"shutdown", "quit"}) + if err != nil { + return err + } if response == "quit" { return fmt.Errorf("domain must be shut off but is \"%s\"", state) } diff --git a/hypervisor/manager/api.go b/hypervisor/manager/api.go index 98391513..2a37ab08 100644 --- a/hypervisor/manager/api.go +++ b/hypervisor/manager/api.go @@ -34,7 +34,7 @@ type Manager struct { numCPU int serialNumber string volumeDirectories []string - mutex sync.RWMutex // Lock everthing below (those can change). + mutex sync.RWMutex // Lock everything below (those can change). addressPool addressPoolType healthStatus string notifiers map[<-chan proto.Update]chan<- proto.Update diff --git a/lib/connpool/api.go b/lib/connpool/api.go index d1d8cc91..4e082a2d 100644 --- a/lib/connpool/api.go +++ b/lib/connpool/api.go @@ -117,7 +117,7 @@ func (cr *ConnResource) GetWithDialer(cancelChannel <-chan struct{}, return cr.get(cancelChannel, dialer) } -// ScheduleClose will immediatly Close the associated Conn if it is not in use +// ScheduleClose will immediately Close the associated Conn if it is not in use // or will mark the Conn to be closed when it is next Put. func (cr *ConnResource) ScheduleClose() { cr.resource.ScheduleRelease() diff --git a/lib/cpusharer/api.go b/lib/cpusharer/api.go index 82e95020..f72c54e2 100644 --- a/lib/cpusharer/api.go +++ b/lib/cpusharer/api.go @@ -100,7 +100,7 @@ func (s *FifoCpuSharer) GoWhenIdle(minIdleTime, timeout time.Duration, // GrabCpu will grab a CPU for use. If there are none available (i.e. all CPUs // are in use by other co-operating goroutines) then this will block until a CPU -// is available. Grab requests are fullfilled in the order they are made. +// is available. Grab requests are fulfilled in the order they are made. func (s *FifoCpuSharer) GrabCpu() { s.grabCpu() } @@ -117,7 +117,7 @@ func (s *FifoCpuSharer) GrabIdleCpu(minIdleTime, timeout time.Duration) bool { } // GrabSemaphore will safely grab the provided semaphore, releasing and -// re-aquiring the CPU if the semaphore blocks. Use this to avoid deadlocks. +// re-acquiring the CPU if the semaphore blocks. Use this to avoid deadlocks. func (s *FifoCpuSharer) GrabSemaphore(semaphore chan<- struct{}) { grabSemaphore(s, semaphore) } diff --git a/lib/cpusharer/fifo.go b/lib/cpusharer/fifo.go index 122c1283..488d26ac 100644 --- a/lib/cpusharer/fifo.go +++ b/lib/cpusharer/fifo.go @@ -107,7 +107,7 @@ func (s *FifoCpuSharer) grabIdleCpu(minIdleTime, timeout time.Duration) bool { time.Sleep(minIdleTime) select { case s.semaphore <- struct{}{}: // A CPU was idle. - default: // No idle CPU: try agin. + default: // No idle CPU: try again. continue } } diff --git a/lib/filesystem/scanner/walk.go b/lib/filesystem/scanner/walk.go index 6d7a21fd..82f1ef35 100644 --- a/lib/filesystem/scanner/walk.go +++ b/lib/filesystem/scanner/walk.go @@ -96,7 +96,6 @@ func scanFileSystem(rootDirectoryName string, err, _ := scanDirectory(&fileSystem.FileSystem.DirectoryInode, oldDirectory, &fileSystem, oldFS, "/") oldFS = nil - oldDirectory = nil if err != nil { return nil, err } diff --git a/lib/filesystem/util/replaceComputedFiles.go b/lib/filesystem/util/replaceComputedFiles.go index 9495356c..59a6e38e 100644 --- a/lib/filesystem/util/replaceComputedFiles.go +++ b/lib/filesystem/util/replaceComputedFiles.go @@ -135,6 +135,9 @@ func (objectsGetter *combinedObjectsGetter) scanDirectory(realDir string, } names, err := file.Readdirnames(-1) file.Close() + if err != nil { + return err + } for _, name := range names { realPath := path.Join(realDir, name) mapPath := path.Join(mapDir, name) diff --git a/lib/filter/api.go b/lib/filter/api.go index 47831c70..9c9e53b9 100644 --- a/lib/filter/api.go +++ b/lib/filter/api.go @@ -7,7 +7,7 @@ import ( // A Filter contains a list of regular expressions matching pathnames which // should be filtered out: excluded when building or not changed when pushing // images to a sub. -// A Filter with no lines is an empty filter (nothing is excluded, everthing is +// A Filter with no lines is an empty filter (nothing is excluded, everything is // changed when pushing). // A nil *Filter is a sparse filter: when building nothing is excluded. When // pushing to a sub, all files are pushed but files on the sub which are not in diff --git a/lib/fsutil/waitFile_test.go b/lib/fsutil/waitFile_test.go index 8bdc4192..e5e010d8 100644 --- a/lib/fsutil/waitFile_test.go +++ b/lib/fsutil/waitFile_test.go @@ -17,7 +17,7 @@ func TestWaitFile(t *testing.T) { pathNotExist := path.Join(dirname, "never-exists") rc, err := WaitFile(pathNotExist, time.Microsecond) if err == nil { - t.Errorf("Expected timeout error for non-existant file") + t.Errorf("Expected timeout error for non-existent file") rc.Close() } pathExists := path.Join(dirname, "exists") @@ -45,7 +45,7 @@ func TestWaitFile(t *testing.T) { rc, err = WaitFile(pathExistsLater, time.Millisecond*10) if err == nil { rc.Close() - t.Errorf("Expected timeout error for non-existant file") + t.Errorf("Expected timeout error for non-existent file") } rc, err = WaitFile(pathExistsLater, time.Millisecond*90) if err != nil { diff --git a/lib/fsutil/watchFile_test.go b/lib/fsutil/watchFile_test.go index a4330e9a..81fcdbe3 100644 --- a/lib/fsutil/watchFile_test.go +++ b/lib/fsutil/watchFile_test.go @@ -47,7 +47,7 @@ func testWatchFile(t *testing.T, dirname string) { rc, err := watchTimeout(ch, time.Millisecond*50) if err != errorTimeout { rc.Close() - t.Fatal("Expected timeout error for non-existant file") + t.Fatal("Expected timeout error for non-existent file") } pathExists := path.Join(dirname, "exists") file, err := os.Create(pathExists) @@ -74,7 +74,7 @@ func testWatchFile(t *testing.T, dirname string) { ch = WatchFile(pathExistsLater, logger) _, err = watchTimeout(ch, time.Millisecond*10) if err != errorTimeout { - t.Fatal("Expected timeout error for non-existant file") + t.Fatal("Expected timeout error for non-existent file") } rc, err = watchTimeout(ch, time.Millisecond*90) if err != nil { diff --git a/lib/net/reverseconnection/listener.go b/lib/net/reverseconnection/listener.go index fe337f5f..706cc615 100644 --- a/lib/net/reverseconnection/listener.go +++ b/lib/net/reverseconnection/listener.go @@ -202,21 +202,18 @@ func (l *Listener) connectLoop(config ReverseListenerConfig, continue } if message.MinimumInterval >= time.Second { - newMinimumInterval := message.MinimumInterval - newMaximumInterval := config.MaximumInterval - if message.MaximumInterval > newMinimumInterval { - newMaximumInterval = message.MaximumInterval - } else { - newMaximumInterval = newMinimumInterval * 11 / 10 + newMaximumInterval := message.MaximumInterval + if newMaximumInterval <= message.MinimumInterval { + newMaximumInterval = message.MinimumInterval * 11 / 10 } - if newMinimumInterval != config.MinimumInterval || + if message.MinimumInterval != config.MinimumInterval || newMaximumInterval != config.MaximumInterval { logger.Debugf(0, "min interval: %s -> %s, max interval: %s -> %s\n", - config.MinimumInterval, newMinimumInterval, + config.MinimumInterval, message.MinimumInterval, config.MaximumInterval, newMaximumInterval) } - config.MinimumInterval = newMinimumInterval + config.MinimumInterval = message.MinimumInterval config.MaximumInterval = newMaximumInterval } } diff --git a/lib/net/rpc/rpc.go b/lib/net/rpc/rpc.go index 663a0736..d6d6ff6c 100644 --- a/lib/net/rpc/rpc.go +++ b/lib/net/rpc/rpc.go @@ -27,8 +27,7 @@ func dialHTTPPath(dialer net.Dialer, network, address, path string) ( return nil, err } io.WriteString(conn, "CONNECT "+path+" HTTP/1.0\n\n") - - // Require successful HTTP reponse before switching to RPC protocol + // Require successful HTTP response before switching to RPC protocol resp, err := http.ReadResponse( bufio.NewReader(conn), &http.Request{Method: "CONNECT"}) // The status value is undocumented and subject to change! diff --git a/lib/net/terminal/client/impl.go b/lib/net/terminal/client/impl.go index ee748f4a..7f189bfc 100644 --- a/lib/net/terminal/client/impl.go +++ b/lib/net/terminal/client/impl.go @@ -14,10 +14,6 @@ type flushWriter interface { } func startTerminal(conn FlushReadWriter) error { - closed := false - defer func() { - closed = true - }() oldState, err := terminal.MakeRaw(int(os.Stdin.Fd())) if err != nil { return err diff --git a/lib/objectcache/filename.go b/lib/objectcache/filename.go index 632eea8e..4ea78317 100644 --- a/lib/objectcache/filename.go +++ b/lib/objectcache/filename.go @@ -11,7 +11,7 @@ func filenameToHash(fileName string) (hash.Hash, error) { var prev_nibble byte = 16 index := 0 for _, char := range fileName { - var nibble byte = 16 + var nibble byte if char >= '0' && char <= '9' { nibble = byte(char) - '0' } else if char >= 'a' && char <= 'f' { diff --git a/lib/objectserver/filesystem/add.go b/lib/objectserver/filesystem/add.go index e040e16d..fe931b56 100644 --- a/lib/objectserver/filesystem/add.go +++ b/lib/objectserver/filesystem/add.go @@ -27,7 +27,6 @@ func (objSrv *ObjectServer) addObject(reader io.Reader, length uint64, if err != nil { return hashVal, false, err } - length = uint64(len(data)) filename := path.Join(objSrv.baseDir, objectcache.HashToFilename(hashVal)) // Check for existing object and collision. if isNew, err := objSrv.addOrCompare(hashVal, data, filename); err != nil { diff --git a/lib/objectserver/filesystem/stash.go b/lib/objectserver/filesystem/stash.go index 4fc3a648..5a5b745d 100644 --- a/lib/objectserver/filesystem/stash.go +++ b/lib/objectserver/filesystem/stash.go @@ -63,7 +63,6 @@ func (objSrv *ObjectServer) stashOrVerifyObject(reader io.Reader, if err != nil { return hashVal, nil, err } - length = uint64(len(data)) hashName := objectcache.HashToFilename(hashVal) filename := path.Join(objSrv.baseDir, hashName) // Check for existing object and collision. diff --git a/lib/slavedriver/api.go b/lib/slavedriver/api.go index b5736560..0fba0324 100644 --- a/lib/slavedriver/api.go +++ b/lib/slavedriver/api.go @@ -20,7 +20,7 @@ type SlaveDriver struct { logger log.DebugLogger rollCallTrigger chan<- struct{} slaveTrader SlaveTrader - mutex sync.Mutex // Lock everthing below (those can change). + mutex sync.Mutex // Lock everything below (those can change). busySlaves map[*Slave]struct{} idleSlaves map[*Slave]struct{} zombies map[*Slave]struct{} @@ -43,7 +43,7 @@ type Slave struct { clientAddress string driver *SlaveDriver info SlaveInfo - mutex sync.Mutex // Lock everthing below (those can change). + mutex sync.Mutex // Lock everything below (those can change). client *srpc.Client } diff --git a/lib/slavedriver/smallstack/api.go b/lib/slavedriver/smallstack/api.go index 6a304b7a..26a5f190 100644 --- a/lib/slavedriver/smallstack/api.go +++ b/lib/slavedriver/smallstack/api.go @@ -12,7 +12,7 @@ import ( type SlaveTrader struct { createRequest hyper_proto.CreateVmRequest logger log.DebugLogger - mutex sync.Mutex // Lock everthing below (those can change). + mutex sync.Mutex // Lock everything below (those can change). hypervisor *srpc.Client } diff --git a/lib/srpc/api.go b/lib/srpc/api.go index 1942bcb4..d0ab00d9 100644 --- a/lib/srpc/api.go +++ b/lib/srpc/api.go @@ -395,7 +395,7 @@ func (conn *Conn) RequestReply(request interface{}, reply interface{}) error { // Username will return the username of the client who holds the certificate // used to authenticate the connection to the server. If the connection was not -// authenticated the emtpy string is returned. If the connection is a client +// authenticated the empty string is returned. If the connection is a client // connection, then Username will panic. func (conn *Conn) Username() string { return conn.getUsername()