Skip to content

Commit 02b4c7c

Browse files
committed
libnetwork/drivers/overlay: fix naked returns, output variables
libnetwork/drivers/overlay/encryption.go:370:2: naked return in func `programSA` with 64 lines of code (nakedret) return ^ Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 94afddb commit 02b4c7c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

libnetwork/drivers/overlay/encryption.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ func (d *driver) programInput(vni uint32, add bool) error {
304304
return nil
305305
}
306306

307-
func programSA(localIP, remoteIP net.IP, spi *spi, k *key, dir int, add bool) (fSA *netlink.XfrmState, rSA *netlink.XfrmState, err error) {
307+
func programSA(localIP, remoteIP net.IP, spi *spi, k *key, dir int, add bool) (fSA *netlink.XfrmState, rSA *netlink.XfrmState, lastErr error) {
308308
var (
309309
action = "Removing"
310310
xfrmProgram = ns.NlHandle().XfrmStateDel
@@ -330,6 +330,7 @@ func programSA(localIP, remoteIP net.IP, spi *spi, k *key, dir int, add bool) (f
330330

331331
exists, err := saExists(rSA)
332332
if err != nil {
333+
lastErr = err
333334
exists = !add
334335
}
335336

@@ -356,6 +357,7 @@ func programSA(localIP, remoteIP net.IP, spi *spi, k *key, dir int, add bool) (f
356357

357358
exists, err := saExists(fSA)
358359
if err != nil {
360+
lastErr = err
359361
exists = !add
360362
}
361363

@@ -367,7 +369,7 @@ func programSA(localIP, remoteIP net.IP, spi *spi, k *key, dir int, add bool) (f
367369
}
368370
}
369371

370-
return
372+
return fSA, rSA, lastErr
371373
}
372374

373375
// getMinimalIP returns the address in its shortest form

0 commit comments

Comments
 (0)