Pull request: all: rm var shadowing vol. 3

Updates #2803.

Squashed commit of the following:

commit ce711ae2e08c3714a4e0c6d177c02f7801c05fce
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Mar 11 20:58:40 2021 +0300

    all: imp code, docs

commit e91094e461893c27eda879b33b5ed2c7085510df
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Mar 11 20:42:14 2021 +0300

    all: rm var shadowing vol. 3
This commit is contained in:
Ainar Garipov
2021-03-11 21:30:52 +03:00
parent 4cf44dd1d4
commit 968831c5b9
13 changed files with 47 additions and 39 deletions

View File

@@ -20,7 +20,7 @@ import (
// CheckIfOtherDHCPServersPresentV4 sends a DHCP request to the specified network interface,
// and waits for a response for a period defined by defaultDiscoverTime
func CheckIfOtherDHCPServersPresentV4(ifaceName string) (bool, error) {
func CheckIfOtherDHCPServersPresentV4(ifaceName string) (ok bool, err error) {
iface, err := net.InterfaceByName(ifaceName)
if err != nil {
return false, fmt.Errorf("couldn't find interface by name %s: %w", ifaceName, err)
@@ -86,7 +86,8 @@ func CheckIfOtherDHCPServersPresentV4(ifaceName string) (bool, error) {
}
for {
ok, next, err := tryConn4(req, c, iface)
var next bool
ok, next, err = tryConn4(req, c, iface)
if next {
if err != nil {
log.Debug("dhcpv4: trying a connection: %s", err)
@@ -94,6 +95,7 @@ func CheckIfOtherDHCPServersPresentV4(ifaceName string) (bool, error) {
continue
}
if err != nil {
return false, err
}
@@ -155,7 +157,7 @@ func tryConn4(req *dhcpv4.DHCPv4, c net.PacketConn, iface *net.Interface) (ok, n
// CheckIfOtherDHCPServersPresentV6 sends a DHCP request to the specified network interface,
// and waits for a response for a period defined by defaultDiscoverTime
func CheckIfOtherDHCPServersPresentV6(ifaceName string) (bool, error) {
func CheckIfOtherDHCPServersPresentV6(ifaceName string) (ok bool, err error) {
iface, err := net.InterfaceByName(ifaceName)
if err != nil {
return false, fmt.Errorf("dhcpv6: net.InterfaceByName: %s: %w", ifaceName, err)
@@ -207,7 +209,8 @@ func CheckIfOtherDHCPServersPresentV6(ifaceName string) (bool, error) {
}
for {
ok, next, err := tryConn6(req, c)
var next bool
ok, next, err = tryConn6(req, c)
if next {
if err != nil {
log.Debug("dhcpv6: trying a connection: %s", err)
@@ -215,6 +218,7 @@ func CheckIfOtherDHCPServersPresentV6(ifaceName string) (bool, error) {
continue
}
if err != nil {
return false, err
}