wifi: kill usage of deprecated GTimeVal

We don't care about microsecond precision, so we don't need
GTimeVal anyway.  Just use time(2).
This commit is contained in:
Dan Williams 2012-06-07 13:45:51 -05:00
parent 5e3e19d02b
commit c0131f767f
3 changed files with 16 additions and 36 deletions

View file

@ -143,7 +143,8 @@ struct _NMDeviceWifiPrivate {
guint32 rate;
gboolean enabled; /* rfkilled or not */
glong scheduled_scan_time;
time_t scheduled_scan_time;
time_t request_scan_time;
guint8 scan_interval; /* seconds */
guint pending_scan_id;
guint scanlist_cull_id;
@ -155,8 +156,6 @@ struct _NMDeviceWifiPrivate {
guint periodic_source_id;
guint link_timeout_id;
glong request_scan_time;
NMDeviceWifiCapabilities capabilities;
};
@ -339,8 +338,6 @@ constructor (GType type,
}
priv->ipw_rfkill_state = nm_device_wifi_get_ipw_rfkill_state (self);
priv->request_scan_time = 0;
return object;
}
@ -1460,16 +1457,14 @@ request_scan_cb (NMDevice *device,
{
NMDeviceWifi *self = NM_DEVICE_WIFI (device);
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
GTimeVal now;
if (error) {
dbus_g_method_return_error (context, error);
g_clear_error (&error);
} else {
g_get_current_time (&now);
cancel_pending_scan (self);
request_wireless_scan (self);
priv->request_scan_time = now.tv_sec;
priv->request_scan_time = time (NULL);
dbus_g_method_return (context);
}
@ -1481,10 +1476,8 @@ impl_device_request_scan (NMDeviceWifi *self,
DBusGMethodInvocation *context)
{
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
GTimeVal now;
g_get_current_time (&now);
if (!priv->enabled || now.tv_sec - priv->request_scan_time < 10) {
if (!priv->enabled || (time (NULL) - priv->request_scan_time) < 10) {
dbus_g_method_return (context);
return;
}
@ -1720,13 +1713,11 @@ static void
schedule_scan (NMDeviceWifi *self, gboolean backoff)
{
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
GTimeVal now;
g_get_current_time (&now);
time_t now = time (NULL);
/* Cancel the pending scan if it would happen later than (now + the scan_interval) */
if (priv->pending_scan_id) {
if (now.tv_sec + priv->scan_interval < priv->scheduled_scan_time)
if (now + priv->scan_interval < priv->scheduled_scan_time)
cancel_pending_scan (self);
}
@ -1741,7 +1732,7 @@ schedule_scan (NMDeviceWifi *self, gboolean backoff)
request_wireless_scan,
self);
priv->scheduled_scan_time = now.tv_sec + priv->scan_interval;
priv->scheduled_scan_time = now + priv->scan_interval;
if (backoff && (priv->scan_interval < (SCAN_INTERVAL_MAX / factor))) {
priv->scan_interval += (SCAN_INTERVAL_STEP / factor);
/* Ensure the scan interval will never be less than 20s... */
@ -1903,7 +1894,7 @@ static gboolean
cull_scan_list (NMDeviceWifi *self)
{
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
GTimeVal now;
time_t now = time (NULL);
GSList *outdated_list = NULL;
GSList *elt;
guint32 removed = 0, total = 0;
@ -1916,7 +1907,6 @@ cull_scan_list (NMDeviceWifi *self)
/* Walk the access point list and remove any access points older than
* three times the inactive scan interval.
*/
g_get_current_time (&now);
for (elt = priv->ap_list; elt; elt = g_slist_next (elt), total++) {
NMAccessPoint *ap = elt->data;
const guint prune_interval_s = SCAN_INTERVAL_MAX * 3;
@ -1936,7 +1926,7 @@ cull_scan_list (NMDeviceWifi *self)
&& g_object_get_data (G_OBJECT (ap), WPAS_REMOVED_TAG) == NULL)
continue;
if (nm_ap_get_last_seen (ap) + prune_interval_s < now.tv_sec)
if (nm_ap_get_last_seen (ap) + prune_interval_s < now)
outdated_list = g_slist_append (outdated_list, ap);
}
@ -2026,7 +2016,6 @@ supplicant_iface_bss_updated_cb (NMSupplicantInterface *iface,
{
NMDeviceState state;
NMAccessPoint *ap;
GTimeVal now;
g_return_if_fail (self != NULL);
g_return_if_fail (object_path != NULL);
@ -2039,10 +2028,8 @@ supplicant_iface_bss_updated_cb (NMSupplicantInterface *iface,
/* Update the AP's last-seen property */
ap = get_ap_by_supplicant_path (self, object_path);
if (ap) {
g_get_current_time (&now);
nm_ap_set_last_seen (ap, now.tv_sec);
}
if (ap)
nm_ap_set_last_seen (ap, (guint32) time (NULL));
/* Remove outdated access points */
schedule_scanlist_cull (self);

View file

@ -509,7 +509,6 @@ NMAccessPoint *
nm_ap_new_from_properties (const char *supplicant_path, GHashTable *properties)
{
NMAccessPoint *ap;
GTimeVal cur_time;
const struct ether_addr * addr;
const char bad_bssid1[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
const char bad_bssid2[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
@ -531,8 +530,7 @@ nm_ap_new_from_properties (const char *supplicant_path, GHashTable *properties)
return NULL;
}
g_get_current_time (&cur_time);
nm_ap_set_last_seen (ap, cur_time.tv_sec);
nm_ap_set_last_seen (ap, (guint32) time (NULL));
if (!nm_ap_get_ssid (ap))
nm_ap_set_broadcast (ap, FALSE);

View file

@ -104,7 +104,7 @@ typedef struct {
guint32 blobs_left;
GHashTable * bss_proxies;
guint32 last_scan;
time_t last_scan;
NMSupplicantConfig * cfg;
@ -467,16 +467,13 @@ static void
set_scanning (NMSupplicantInterface *self, gboolean new_scanning)
{
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
GTimeVal cur_time;
if (priv->scanning != new_scanning) {
priv->scanning = new_scanning;
/* Cache time of last scan completion */
if (priv->scanning == FALSE) {
g_get_current_time (&cur_time);
priv->last_scan = cur_time.tv_sec;
}
if (priv->scanning == FALSE)
priv->last_scan = time (NULL);
g_object_notify (G_OBJECT (self), "scanning");
}
@ -504,11 +501,9 @@ wpas_iface_scan_done (DBusGProxy *proxy,
{
NMSupplicantInterface *self = NM_SUPPLICANT_INTERFACE (user_data);
NMSupplicantInterfacePrivate *priv = NM_SUPPLICANT_INTERFACE_GET_PRIVATE (self);
GTimeVal cur_time;
/* Cache last scan completed time */
g_get_current_time (&cur_time);
priv->last_scan = cur_time.tv_sec;
priv->last_scan = time (NULL);
g_signal_emit (self, signals[SCAN_DONE], 0, success);
}