From 051f49ea85976e85ec854bee9e7c13e04e4c42f1 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Thu, 23 Oct 2014 22:44:59 -0500 Subject: [PATCH] wiphy: Tweak netdev structure creation order Because none of the attributes are assigned until after the DeviceAdded signal is emitted, the signal appears with invalid properties. For now, move the netdev structure fill-out into the if statement. If the netdev attributes can change, then these need to be handled separately and appropriate signals to be sent. --- src/wiphy.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/wiphy.c b/src/wiphy.c index 22874289..6871c4a6 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -558,27 +558,27 @@ static void interface_dump_callback(struct l_genl_msg *msg, void *user_data) L_UINT_TO_PTR(ifindex)); if (!netdev) { struct l_dbus *dbus = dbus_get_bus(); - char path[256]; - - snprintf(path, sizeof(path), "/%u", ifindex); netdev = l_new(struct netdev, 1); netdev->bss_list = l_queue_new(); + memcpy(netdev->name, ifname, sizeof(netdev->name)); + memcpy(netdev->addr, ifaddr, sizeof(netdev->addr)); + netdev->index = ifindex; + netdev->type = iftype; + l_queue_push_head(wiphy->netdev_list, netdev); - if (!l_dbus_register_interface(dbus, path, IWD_DEVICE_INTERFACE, - setup_device_interface, netdev, NULL)) + if (!l_dbus_register_interface(dbus, + iwd_device_get_path(netdev), + IWD_DEVICE_INTERFACE, + setup_device_interface, + netdev, NULL)) l_info("Unable to register %s interface", IWD_DEVICE_INTERFACE); else device_emit_added(netdev); } - memcpy(netdev->name, ifname, sizeof(netdev->name)); - memcpy(netdev->addr, ifaddr, sizeof(netdev->addr)); - netdev->index = ifindex; - netdev->type = iftype; - l_debug("Found interface %s", netdev->name); trigger_scan(wiphy);