[PATCH] broadband-modem-qmi: fix incorrect conversions from double to gint32
Aleksander Morgado
aleksander at lanedo.com
Wed Jul 10 23:13:21 PDT 2013
On 11/07/13 05:37, Ben Chan wrote:
> This patch fixes the following incorrect conversions from double to gint32:
>
> mm-broadband-modem-qmi.c:4785:27: error: implicit conversion from 'double' to 'gint32' (aka 'int')
> changes value from 2.225073858507201E-308 to 0 [-Werror,-Wliteral-conversion]
> gint32 bs_longitude = MM_LOCATION_LONGITUDE_UNKNOWN;
> ~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> mm-broadband-modem-qmi.c:4786:26: error: implicit conversion from 'double' to 'gint32' (aka 'int')
> changes value from 2.225073858507201E-308 to 0 [-Werror,-Wliteral-conversion]
> gint32 bs_latitude = MM_LOCATION_LATITUDE_UNKNOWN;
> ~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ---
Nah, don't define BS_LONGITUDE_UNKNOWN and BS_LATITUDE_UNKNOWN; just
initialize the values to G_MININT32 and use it later to compare the value.
> src/mm-broadband-modem-qmi.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c
> index efaefb3..4c412d1 100644
> --- a/src/mm-broadband-modem-qmi.c
> +++ b/src/mm-broadband-modem-qmi.c
> @@ -4772,6 +4772,11 @@ common_process_serving_system_cdma (MMBroadbandModemQmi *self,
> QmiMessageNasGetServingSystemOutput *response_output,
> QmiIndicationNasServingSystemOutput *indication_output)
> {
> + /* Identifier for an unknown base station longitude value. */
> +#define BS_LONGITUDE_UNKNOWN G_MININT32
> + /* Identifier for an unknown base station latitude value. */
> +#define BS_LATITUDE_UNKNOWN G_MININT32
> +
> QmiNasRegistrationState registration_state;
> QmiNasNetworkType selected_network;
> GArray *radio_interfaces;
> @@ -4782,8 +4787,8 @@ common_process_serving_system_cdma (MMBroadbandModemQmi *self,
> guint16 sid = 0;
> guint16 nid = 0;
> guint16 bs_id = 0;
> - gint32 bs_longitude = MM_LOCATION_LONGITUDE_UNKNOWN;
> - gint32 bs_latitude = MM_LOCATION_LATITUDE_UNKNOWN;
> + gint32 bs_longitude = BS_LONGITUDE_UNKNOWN;
> + gint32 bs_latitude = BS_LATITUDE_UNKNOWN;
>
> if (response_output)
> qmi_message_nas_get_serving_system_output_get_serving_system (
> @@ -4933,11 +4938,11 @@ common_process_serving_system_cdma (MMBroadbandModemQmi *self,
> /* Longitude and latitude given in units of 0.25 secs
> * Note that multiplying by 0.25 is like dividing by 4, so 60*60*4=14400 */
> #define QMI_LONGITUDE_TO_DEGREES(longitude) \
> - (longitude != MM_LOCATION_LONGITUDE_UNKNOWN ? \
> + (longitude != BS_LONGITUDE_UNKNOWN ? \
> (((gdouble)longitude) / 14400.0) : \
> MM_LOCATION_LONGITUDE_UNKNOWN)
> #define QMI_LATITUDE_TO_DEGREES(latitude) \
> - (latitude != MM_LOCATION_LATITUDE_UNKNOWN ? \
> + (latitude != BS_LATITUDE_UNKNOWN ? \
> (((gdouble)latitude) / 14400.0) : \
> MM_LOCATION_LATITUDE_UNKNOWN)
>
>
--
Aleksander
More information about the ModemManager-devel
mailing list