From 3a0286431194401067c96510f64222e35a2e2ac8 Mon Sep 17 00:00:00 2001 From: "kj7.sung" Date: Wed, 23 Nov 2016 14:04:04 +0900 Subject: [PATCH] Fix svace issue Change-Id: I4593a860ce442bb7611428cccf322356b00156e5 Signed-off-by: kj7.sung --- module/nps_module.c | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/module/nps_module.c b/module/nps_module.c index 145357b..7a35f42 100644 --- a/module/nps_module.c +++ b/module/nps_module.c @@ -240,34 +240,43 @@ static int get_last_position(gpointer handle, LocationPosition **position, Locat snprintf(location, sizeof(location), "%s", str); free(str); + index = 0; last_location[index] = (char *)strtok_r(location, ";", &last); - while (last_location[index++] != NULL) { - if (index == MAX_NPS_LOC_ITEM) + while (last_location[index] != NULL) { + switch (index) { + case 0: + latitude = strtod(last_location[index], NULL); + break; + case 1: + longitude = strtod(last_location[index], NULL); + break; + case 2: + altitude = strtod(last_location[index], NULL); + break; + case 3: + speed = strtod(last_location[index], NULL); + break; + case 4: + direction = strtod(last_location[index], NULL); + break; + case 5: + hor_accuracy = strtod(last_location[index], NULL); + break; + default: break; + } + if (++index == MAX_NPS_LOC_ITEM) break; last_location[index] = (char *)strtok_r(NULL, ";", &last); } - - if (index != MAX_NPS_LOC_ITEM) { - MOD_NPS_LOGD("Error item index"); - return LOCATION_ERROR_NOT_AVAILABLE; - } - index = 0; - latitude = strtod(last_location[index++], NULL); - longitude = strtod(last_location[index++], NULL); - altitude = strtod(last_location[index++], NULL); - speed = strtod(last_location[index++], NULL); - direction = strtod(last_location[index++], NULL); - hor_accuracy = strtod(last_location[index], NULL); } } - level = LOCATION_ACCURACY_LEVEL_STREET; - if (timestamp) status = LOCATION_STATUS_3D_FIX; else return LOCATION_ERROR_NOT_AVAILABLE; + level = LOCATION_ACCURACY_LEVEL_STREET; *position = location_position_new((guint) timestamp, latitude, longitude, altitude, status); *velocity = location_velocity_new((guint) timestamp, speed, direction, 0.0); *accuracy = location_accuracy_new(level, hor_accuracy, -1.0); -- 2.34.1