Skip to content

Commit

Permalink
Fix ineffective assignments/swallowed errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
rgooch committed Apr 14, 2019
1 parent 98d4de9 commit ea125f9
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 16 deletions.
3 changes: 3 additions & 0 deletions cmd/installer/configureLocalNetwork.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
5 changes: 2 additions & 3 deletions cmd/installer/configureStorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions cmd/vm-control/importVirshVm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 0 additions & 1 deletion lib/filesystem/scanner/walk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 3 additions & 0 deletions lib/filesystem/util/replaceComputedFiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 6 additions & 9 deletions lib/net/reverseconnection/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/objectcache/filename.go
Original file line number Diff line number Diff line change
Expand Up @@ -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' {
Expand Down
1 change: 0 additions & 1 deletion lib/objectserver/filesystem/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion lib/objectserver/filesystem/stash.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit ea125f9

Please sign in to comment.