Skip to content

Commit eba31a7

Browse files
committed
libct/StartInitialization: rename returned error
This is a cosmetic change to improve code readability, making it easier to distinguish between a local error and the error being returned. While at it, rename e to err (it was originally called e to not clash with returned error named err) and ee to err2. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 4f0a7e7 commit eba31a7

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

libcontainer/init_linux.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ type initConfig struct {
7676
// StartInitialization loads a container by opening the pipe fd from the parent
7777
// to read the configuration and state. This is a low level implementation
7878
// detail of the reexec and should not be consumed externally.
79-
func StartInitialization() (err error) {
79+
func StartInitialization() (retErr error) {
8080
// Get the INITPIPE.
8181
envInitPipe := os.Getenv("_LIBCONTAINER_INITPIPE")
8282
pipefd, err := strconv.Atoi(envInitPipe)
@@ -91,12 +91,12 @@ func StartInitialization() (err error) {
9191
defer func() {
9292
// We have an error during the initialization of the container's init,
9393
// send it back to the parent process in the form of an initError.
94-
if werr := writeSync(pipe, procError); werr != nil {
95-
fmt.Fprintln(os.Stderr, err)
94+
if err := writeSync(pipe, procError); err != nil {
95+
fmt.Fprintln(os.Stderr, retErr)
9696
return
9797
}
98-
if werr := utils.WriteJSON(pipe, &initError{Message: err.Error()}); werr != nil {
99-
fmt.Fprintln(os.Stderr, err)
98+
if err := utils.WriteJSON(pipe, &initError{Message: retErr.Error()}); err != nil {
99+
fmt.Fprintln(os.Stderr, retErr)
100100
return
101101
}
102102
}()
@@ -139,11 +139,11 @@ func StartInitialization() (err error) {
139139
os.Clearenv()
140140

141141
defer func() {
142-
if e := recover(); e != nil {
143-
if ee, ok := e.(error); ok {
144-
err = fmt.Errorf("panic from initialization: %w, %s", ee, debug.Stack())
142+
if err := recover(); err != nil {
143+
if err2, ok := err.(error); ok {
144+
retErr = fmt.Errorf("panic from initialization: %w, %s", err2, debug.Stack())
145145
} else {
146-
err = fmt.Errorf("panic from initialization: %v, %s", e, debug.Stack())
146+
retErr = fmt.Errorf("panic from initialization: %v, %s", err, debug.Stack())
147147
}
148148
}
149149
}()

0 commit comments

Comments
 (0)