Commit ac1f3bfa authored by Arthur Silva's avatar Arthur Silva Committed by Matt Holt

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
parent f7a70266
...@@ -565,12 +565,7 @@ func ValidateAndExecuteDirectives(cdyfile Input, inst *Instance, justValidate bo ...@@ -565,12 +565,7 @@ func ValidateAndExecuteDirectives(cdyfile Input, inst *Instance, justValidate bo
return err return err
} }
err = executeDirectives(inst, cdyfile.Path(), stype.Directives(), sblocks, justValidate) return executeDirectives(inst, cdyfile.Path(), stype.Directives(), sblocks, justValidate)
if err != nil {
return err
}
return nil
} }
func executeDirectives(inst *Instance, filename string, func executeDirectives(inst *Instance, filename string,
......
...@@ -84,7 +84,7 @@ func trapSignalsPosix() { ...@@ -84,7 +84,7 @@ func trapSignalsPosix() {
} }
// Kick off the restart; our work is done // Kick off the restart; our work is done
inst, err = inst.Restart(caddyfileToUse) _, err = inst.Restart(caddyfileToUse)
if err != nil { if err != nil {
log.Printf("[ERROR] SIGUSR1: %v", err) log.Printf("[ERROR] SIGUSR1: %v", err)
} }
......
...@@ -148,7 +148,7 @@ func Upgrade() error { ...@@ -148,7 +148,7 @@ func Upgrade() error {
// determine whether child startup succeeded // determine whether child startup succeeded
answer, readErr := ioutil.ReadAll(sigrpipe) answer, readErr := ioutil.ReadAll(sigrpipe)
if answer == nil || len(answer) == 0 { if len(answer) == 0 {
cmdErr := cmd.Wait() // get exit status cmdErr := cmd.Wait() // get exit status
errStr := fmt.Sprintf("child failed to initialize: %v", cmdErr) errStr := fmt.Sprintf("child failed to initialize: %v", cmdErr)
if readErr != nil { if readErr != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment