cherry-pick: home: fix types

Updates #4424.

Squashed commit of the following:

commit 784b4940d46ce74edbfbbde6e5b24f95dcb4bc70
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Thu Mar 24 17:07:41 2022 +0300

    home: fix types
This commit is contained in:
Ainar Garipov 2022-03-24 17:12:41 +03:00 committed by Ainar Garipov
parent d27c3284f6
commit b114fd5279
1 changed files with 7 additions and 1 deletions

View File

@ -332,8 +332,14 @@ type tcpPort int
// ports should be either a udpPort or a tcpPort. // ports should be either a udpPort or a tcpPort.
func addPorts(uc aghalg.UniqChecker, ports ...interface{}) { func addPorts(uc aghalg.UniqChecker, ports ...interface{}) {
for _, p := range ports { for _, p := range ports {
// Use separate cases for tcpPort and udpPort so that the untyped
// constant zero is converted to the appropriate type.
switch p := p.(type) { switch p := p.(type) {
case tcpPort, udpPort: case tcpPort:
if p != 0 {
uc.Add(p)
}
case udpPort:
if p != 0 { if p != 0 {
uc.Add(p) uc.Add(p)
} }