From 2b5c8106adf8f7ac5176349f0411511d33401139 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCller?= Date: Wed, 18 Sep 2019 10:34:39 +0200 Subject: [PATCH] ActiveCOnnection : do not create an object if the path is '/', return nil instead --- ActiveConnection.go | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/ActiveConnection.go b/ActiveConnection.go index 6c00932..48625cb 100644 --- a/ActiveConnection.go +++ b/ActiveConnection.go @@ -160,26 +160,18 @@ func (a *activeConnection) GetPropertyDefault() (bool, error) { func (a *activeConnection) GetPropertyIP4Config() (IP4Config, error) { path, err := a.getObjectProperty(ActiveConnectionPropertyIp4Config) - if err != nil { + if err != nil || path == "/" { return nil, err } - r, err := NewIP4Config(path) - if err != nil { - return nil, err - } - return r, nil + return NewIP4Config(path) } func (a *activeConnection) GetPropertyDHCP4Config() (DHCP4Config, error) { path, err := a.getObjectProperty(ActiveConnectionPropertyDhcp4Config) - if err != nil { + if err != nil || path == "/" { return nil, err } - r, err := NewDHCP4Config(path) - if err != nil { - return nil, err - } - return r, nil + return NewDHCP4Config(path) } func (a *activeConnection) GetPropertyDefault6() (bool, error) { @@ -214,12 +206,8 @@ func (a *activeConnection) GetPropertyVPN() (bool, error) { func (a *activeConnection) GetPropertyMaster() (Device, error) { path, err := a.getObjectProperty(ActiveConnectionPropertyMaster) - if err != nil { + if err != nil || path == "/" { return nil, err } - r, err := DeviceFactory(path) - if err != nil { - return nil, err - } - return r, nil + return DeviceFactory(path) }