From bfbfab3741b76797cb1da6dd9a7446545e7bda18 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 15 Oct 2020 13:54:56 +1100 Subject: [PATCH] network: Allow convertToInterface to fail There's nothing in there which can fail now, but I'm planning to add something, and it turns out it's pretty easy for the single caller to handle. Signed-off-by: David Gibson --- virtcontainers/kata_agent.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/virtcontainers/kata_agent.go b/virtcontainers/kata_agent.go index e897a2cca1..b67cf688cf 100644 --- a/virtcontainers/kata_agent.go +++ b/virtcontainers/kata_agent.go @@ -673,7 +673,10 @@ func (k *kataAgent) listInterfaces() ([]*vcTypes.Interface, error) { } resultInterfaces, ok := resultingInterfaces.(*grpc.Interfaces) if ok { - return k.convertToInterfaces(resultInterfaces.Interfaces), err + ifaces, err := k.convertToInterfaces(resultInterfaces.Interfaces) + if err == nil { + return ifaces, nil + } } return nil, err } @@ -2301,7 +2304,8 @@ func (k *kataAgent) convertToKataAgentInterface(iface *vcTypes.Interface) *aType } } -func (k *kataAgent) convertToInterfaces(aIfaces []*aTypes.Interface) (ifaces []*vcTypes.Interface) { +func (k *kataAgent) convertToInterfaces(aIfaces []*aTypes.Interface) ([]*vcTypes.Interface, error) { + ifaces := make([]*vcTypes.Interface, 0) for _, aIface := range aIfaces { if aIface == nil { continue @@ -2319,7 +2323,7 @@ func (k *kataAgent) convertToInterfaces(aIfaces []*aTypes.Interface) (ifaces []* ifaces = append(ifaces, iface) } - return ifaces + return ifaces, nil } func (k *kataAgent) convertToKataAgentRoutes(routes []*vcTypes.Route) (aRoutes []*aTypes.Route) {