diff --git a/client.go b/client.go index 3c5630e..1d14a7b 100644 --- a/client.go +++ b/client.go @@ -49,6 +49,9 @@ func (c *Client) BSS(ifi *Interface) (*BSS, error) { } // StationInfo retrieves all station statistics about a WiFi interface. +// +// Since v0.2.0: if there are no stations, an empty slice is returned instead +// of an error. func (c *Client) StationInfo(ifi *Interface) ([]*StationInfo, error) { return c.c.StationInfo(ifi) } diff --git a/client_linux.go b/client_linux.go index a1a5e31..22edcc3 100644 --- a/client_linux.go +++ b/client_linux.go @@ -185,10 +185,6 @@ func (c *client) StationInfo(ifi *Interface) ([]*StationInfo, error) { return nil, err } - if len(msgs) == 0 { - return nil, os.ErrNotExist - } - stations := make([]*StationInfo, len(msgs)) for i := range msgs { if stations[i], err = parseStationInfo(msgs[i].Data); err != nil { diff --git a/client_linux_test.go b/client_linux_test.go index c886f61..de51ba8 100644 --- a/client_linux_test.go +++ b/client_linux_test.go @@ -256,12 +256,15 @@ func TestLinux_clientStationInfoNoMessagesIsNotExist(t *testing.T) { return nil, io.EOF }) - _, err := c.StationInfo(&Interface{ + info, err := c.StationInfo(&Interface{ Index: 1, HardwareAddr: net.HardwareAddr{0xe, 0xad, 0xbe, 0xef, 0xde, 0xad}, }) - if !os.IsNotExist(err) { - t.Fatalf("expected is not exist, got: %v", err) + if err != nil { + t.Fatalf("undexpected error: %v", err) + } + if !reflect.DeepEqual(info, []*StationInfo{}) { + t.Fatalf("expected info to be an empty slice, got %v", info) } }