Fix SVACE & Coverity issues 82/173182/1 accepted/tizen/unified/20180322.060210 submit/tizen/20180320.110142 submit/tizen/20180321.023352 submit/tizen/20180321.074218
authorchanywa <cbible.kim@samsung.com>
Tue, 20 Mar 2018 02:45:40 +0000 (11:45 +0900)
committerchanywa <cbible.kim@samsung.com>
Tue, 20 Mar 2018 02:45:40 +0000 (11:45 +0900)
Change-Id: I450b89f6f25c7bd634a46845f7dc5de5db150eb0

capi-maps-service.changes
packaging/capi-maps-service.spec
src/api/maps_service.cpp
src/api/maps_view_snapshot.cpp
src/view/inertial_gesture.cpp

index 9bfd8cb..da85e73 100644 (file)
@@ -1,3 +1,8 @@
+[Version]   capi-maps-service_0.6.19
+[Date]      20 Mar 2018
+[Title]     Fix SVACE & Coverity issues
+[Developer] Seechan Kim <cbible.kim@samsung.com>
+
 [Version]   capi-maps-service_0.6.18
 [Date]      04 Dec 2017
 [Title]     Revise to return NOT_FOUND error when any map provider wasn't found
index 1fd23d8..75ced93 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-maps-service
 Summary:    Tizen Maps Service API
-Version:    0.6.18
+Version:    0.6.19
 Release:    1
 Group:      Location/API
 License:    Apache-2.0
index e3ea040..3be1f8b 100644 (file)
@@ -46,6 +46,17 @@ plugin::plugin_s *__extract_plugin(maps_service_h maps)
        return (plugin::plugin_s *) maps_service->plugin;
 }
 
+int __run_cmd(session::command* cmd)
+{
+       int ret = MAPS_ERROR_INVALID_PARAMETER;
+       if (cmd) {
+               if (cmd->plugin()) ret = cmd->run();
+               else delete cmd;
+       }
+       if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
+       return ret;
+}
+
 /*----------------------------------------------------------------------------*/
 /* */
 /* Maps Service & Preference */
@@ -383,9 +394,7 @@ EXPORT_API int maps_service_geocode(const maps_service_h maps,
        session::command *cmd = new (std::nothrow) session::command_geocode(maps, address, preference,
                        callback, user_data, request_id);
 
-       int ret = (cmd && cmd->plugin()) ? cmd->run() : MAPS_ERROR_INVALID_PARAMETER;
-       if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
-       return ret;
+       return __run_cmd(cmd);
 }
 
 EXPORT_API int maps_service_geocode_inside_area(const maps_service_h maps,
@@ -418,9 +427,7 @@ EXPORT_API int maps_service_geocode_inside_area(const maps_service_h maps,
        session::command *cmd = new (std::nothrow) session::command_geocode_inside_bounds(maps,
                        address, bounds, preference, callback, user_data, request_id);
 
-       int ret = (cmd && cmd->plugin()) ? cmd->run() : MAPS_ERROR_INVALID_PARAMETER;
-       if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
-       return ret;
+       return __run_cmd(cmd);
 }
 
 EXPORT_API int maps_service_geocode_by_structured_address(const maps_service_h maps,
@@ -491,9 +498,7 @@ EXPORT_API int maps_service_reverse_geocode(const maps_service_h maps,
        session::command *cmd = new (std::nothrow) session::command_reverse_geocode(maps, latitude,
                        longitude, preference, callback, user_data, request_id);
 
-       int ret = (cmd && cmd->plugin()) ? cmd->run() : MAPS_ERROR_INVALID_PARAMETER;
-       if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
-       return ret;
+       return __run_cmd(cmd);
 }
 
 /*----------------------------------------------------------------------------*/
@@ -531,9 +536,7 @@ EXPORT_API int maps_service_search_place(const maps_service_h maps,
        session::command *cmd = new (std::nothrow) session::command_search_place(maps, position,
                        distance, preference, filter, callback, user_data, request_id);
 
-       int ret = (cmd && cmd->plugin()) ? cmd->run() : MAPS_ERROR_INVALID_PARAMETER;
-       if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
-       return ret;
+       return __run_cmd(cmd);
 }
 
 EXPORT_API int maps_service_search_place_by_area(const maps_service_h maps,
@@ -567,9 +570,7 @@ EXPORT_API int maps_service_search_place_by_area(const maps_service_h maps,
        session::command *cmd = new (std::nothrow) session::command_search_by_area_place(maps,
                        boundary, preference, filter, callback, user_data, request_id);
 
-       int ret = (cmd && cmd->plugin()) ? cmd->run() : MAPS_ERROR_INVALID_PARAMETER;
-       if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
-       return ret;
+       return __run_cmd(cmd);
 }
 
 EXPORT_API int maps_service_search_place_by_address(const maps_service_h maps,
@@ -604,9 +605,7 @@ EXPORT_API int maps_service_search_place_by_address(const maps_service_h maps,
        session::command *cmd = new (std::nothrow) session::command_search_by_address_place(maps,
                        address, boundary, preference, filter, callback, user_data, request_id);
 
-       int ret = (cmd && cmd->plugin()) ? cmd->run() : MAPS_ERROR_INVALID_PARAMETER;
-       if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
-       return ret;
+       return __run_cmd(cmd);
 }
 
 EXPORT_API int maps_service_search_place_list(const maps_service_h maps,
@@ -635,9 +634,7 @@ EXPORT_API int maps_service_search_place_list(const maps_service_h maps,
        session::command *cmd = new (std::nothrow) session::command_search_place_list(maps,
                        boundary, preference, filter, callback, user_data, request_id);
 
-       int ret = (cmd && cmd->plugin()) ? cmd->run() : MAPS_ERROR_INVALID_PARAMETER;
-       if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
-       return ret;
+       return __run_cmd(cmd);
 }
 
 EXPORT_API int maps_service_get_place_details(const maps_service_h maps,
@@ -663,9 +660,7 @@ EXPORT_API int maps_service_get_place_details(const maps_service_h maps,
        session::command *cmd = new (std::nothrow) session::command_get_place_details(maps,
                        url, callback, user_data, request_id);
 
-       int ret = (cmd && cmd->plugin()) ? cmd->run() : MAPS_ERROR_INVALID_PARAMETER;
-       if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
-       return ret;
+       return __run_cmd(cmd);
 }
 
 /*----------------------------------------------------------------------------*/
@@ -702,9 +697,7 @@ EXPORT_API int maps_service_search_route(const maps_service_h maps,
        session::command *cmd = new (std::nothrow) session::command_search_route(maps, preference,
                        origin, destination, callback, user_data, request_id);
 
-       int ret = (cmd && cmd->plugin()) ? cmd->run() : MAPS_ERROR_INVALID_PARAMETER;
-       if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
-       return ret;
+       return __run_cmd(cmd);
 }
 
 EXPORT_API int maps_service_search_route_waypoints(const maps_service_h maps,
@@ -739,9 +732,7 @@ EXPORT_API int maps_service_search_route_waypoints(const maps_service_h maps,
        session::command *cmd = new (std::nothrow) session::command_search_route_waypoints(maps,
                        preference, waypoint_list, waypoint_num, callback, user_data, request_id);
 
-       int ret = (cmd && cmd->plugin()) ? cmd->run() : MAPS_ERROR_INVALID_PARAMETER;
-       if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
-       return ret;
+       return __run_cmd(cmd);
 }
 
 /*----------------------------------------------------------------------------*/
@@ -771,9 +762,7 @@ EXPORT_API int maps_service_cancel_request(const maps_service_h maps, int reques
 
        session::command *cmd = new (std::nothrow) session::command_cancel_request(maps, request_id);
 
-       int ret = (cmd && cmd->plugin()) ? cmd->run() : MAPS_ERROR_INVALID_PARAMETER;
-       if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
-       return ret;
+       return __run_cmd(cmd);
 }
 
 /*----------------------------------------------------------------------------*/
@@ -802,8 +791,6 @@ EXPORT_API int maps_service_multi_reverse_geocode(const maps_service_h maps,
        session::command *cmd = new (std::nothrow) session::command_multi_reverse_geocode(maps,
                        coordinates_list, preference, callback, user_data, request_id);
 
-       int ret = (cmd && cmd->plugin()) ? cmd->run() : MAPS_ERROR_INVALID_PARAMETER;
-       if (ret) MAPS_LOGE("Failed to run command.(%d)", ret);
-       return ret;
+       return __run_cmd(cmd);
 }
 
index b73842a..e7229b2 100644 (file)
@@ -275,9 +275,13 @@ EXPORT_API int maps_view_capture_snapshot(maps_view_h view,
 
        if (tmp_path) {
                if (error == MAPS_ERROR_NONE) {
-                       MAPS_LOGD("The snapshot is saved to %s", path);
                        remove(path);
-                       rename(tmp_path, path);
+                       if (rename(tmp_path, path) == 0) {
+                               MAPS_LOGD("The snapshot is saved to %s", path);
+                       } else {
+                               error = MAPS_ERROR_INVALID_OPERATION;
+                               MAPS_LOGE("Failed to save the snapshot file to %s", path);
+                       }
                } else {
                        remove(tmp_path);
                }
index acb8060..d3e36e8 100644 (file)
@@ -77,9 +77,9 @@ void view::inertial_gesture::tap(int finger_no, const touch_point &tp)
 
                        unsigned int timestamp = _last[i]._timestamp + get_transition_time(i);
 
-                       const touch_point tp(_cur_x[i], _cur_y[i], timestamp);
-                       MAPS_LOGI("TRANSITION finger %d up FAKE BRAKE time: %d", i, tp._timestamp);
-                       _d->up(i, tp);
+                       const touch_point finger_tp(_cur_x[i], _cur_y[i], timestamp);
+                       MAPS_LOGI("TRANSITION finger %d up FAKE BRAKE time: %d", i, finger_tp._timestamp);
+                       _d->up(i, finger_tp);
                }
 
                _d->halt_gesture();