a few code improvements (#1936)

caddy.go:569: could be simplified

sigtrap_posix.go:87: value of inst is never used

upgrade.go:151: should omit nil check; len() for nil slices is defined as zero
This commit is contained in:
Arthur Silva 2017-10-31 14:12:05 -02:00 committed by Matt Holt
parent f7a70266ed
commit ac1f3bfaaa
3 changed files with 3 additions and 8 deletions

View File

@ -565,12 +565,7 @@ func ValidateAndExecuteDirectives(cdyfile Input, inst *Instance, justValidate bo
return err
}
err = executeDirectives(inst, cdyfile.Path(), stype.Directives(), sblocks, justValidate)
if err != nil {
return err
}
return nil
return executeDirectives(inst, cdyfile.Path(), stype.Directives(), sblocks, justValidate)
}
func executeDirectives(inst *Instance, filename string,

View File

@ -84,7 +84,7 @@ func trapSignalsPosix() {
}
// Kick off the restart; our work is done
inst, err = inst.Restart(caddyfileToUse)
_, err = inst.Restart(caddyfileToUse)
if err != nil {
log.Printf("[ERROR] SIGUSR1: %v", err)
}

View File

@ -148,7 +148,7 @@ func Upgrade() error {
// determine whether child startup succeeded
answer, readErr := ioutil.ReadAll(sigrpipe)
if answer == nil || len(answer) == 0 {
if len(answer) == 0 {
cmdErr := cmd.Wait() // get exit status
errStr := fmt.Sprintf("child failed to initialize: %v", cmdErr)
if readErr != nil {