wimax: fix dbus-glib assert when wimax strength overflows

Ran into a case right underneath a tower where the Intel WiMAX SDK
reported signal strength as 32767 which is pretty clearly an overflow
of a 16-bit int somewhere in the WiMAX stack.  Since our internal
NMWimaxNsp GObject property for signal-quality has a max value of
100, dbus-glib got pretty angry when GObject failed to return
something because the property value was out of range, leading
to malformed message and the bus daemon kicking us off, and finally
an assertion somewhere.  Fun.
This commit is contained in:
Dan Williams 2011-03-11 18:20:42 -06:00
parent 16948ce927
commit 0e348bad2a
2 changed files with 2 additions and 2 deletions

View file

@ -1075,7 +1075,7 @@ wmx_scan_result_cb (struct wmxsdk *wmxsdk,
if (net_type != nm_wimax_nsp_get_network_type (nsp))
g_object_set (nsp, NM_WIMAX_NSP_NETWORK_TYPE, net_type, NULL);
signalq = sdk_nsp->linkQuality;
signalq = CLAMP (sdk_nsp->linkQuality, 0, 100);
if (signalq != nm_wimax_nsp_get_signal_quality (nsp))
g_object_set (nsp, NM_WIMAX_NSP_SIGNAL_QUALITY, signalq, NULL);

View file

@ -146,7 +146,7 @@ set_property (GObject *object, guint prop_id,
case PROP_SIGNAL_QUALITY:
quality = g_value_get_uint (value);
if (quality != priv->signal_quality) {
priv->signal_quality = quality;
priv->signal_quality = CLAMP (quality, 0, 100);
g_object_notify (object, NM_WIMAX_NSP_SIGNAL_QUALITY);
}
break;