From: Piotr Kosko Date: Tue, 8 May 2018 05:53:49 +0000 (+0200) Subject: [Filesystem][Alarm] Fix coverity/SVACE issues X-Git-Tag: submit/tizen/20180508.125915^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F10%2F178110%2F2;p=platform%2Fcore%2Fapi%2Fwebapi-plugins.git [Filesystem][Alarm] Fix coverity/SVACE issues [Bug] Fixed Coverity issues: 119865, 119863. Fixed SVACE issue: 345864 Issues were related to not reachable code (invalid returned value was checked) in Alarm module and not checking returned values in Filesystem module. SVACE issue 345864 is related to the same problem as Coverity 119863. [Verification] Code compiles without errors. TCT passrate for Alarm and Filesystem - 100%. Change-Id: I315d0aed94f8efef13d37a73b313ef455fb3b00e Signed-off-by: Piotr Kosko --- diff --git a/src/alarm/alarm_manager.cc b/src/alarm/alarm_manager.cc index 1669bb6f..7a27dfcc 100644 --- a/src/alarm/alarm_manager.cc +++ b/src/alarm/alarm_manager.cc @@ -630,7 +630,7 @@ PlatformResult AlarmManager::GetAlarm(int id, picojson::object& obj) { } int ret_app = app_control_get_extra_data(app_control, kAlarmRelativeDelayKey, &delay_string); - if (APP_CONTROL_ERROR_NONE != ret) { + if (APP_CONTROL_ERROR_NONE != ret_app) { return LogAndCreateResult(ErrorCode::NOT_FOUND_ERR, "Failed to get data.", ("Failed to get data: %d (%s)", ret_app, get_error_message(ret_app))); } diff --git a/src/filesystem/filesystem_manager.cc b/src/filesystem/filesystem_manager.cc index ad518b07..755defb5 100644 --- a/src/filesystem/filesystem_manager.cc +++ b/src/filesystem/filesystem_manager.cc @@ -327,14 +327,20 @@ void FilesystemManager::Rename(const std::string oldPath, const std::string& new ret |= chown(newPath.c_str(), fileStat.st_uid, fileStat.st_gid); if (0 != ret) { LoggerE("Error while changing ownership/permissions [%s]", GetErrorString(errno).c_str()); - remove(newPath.c_str()); + if (0 != remove(newPath.c_str())) { + LoggerW("Error during rollback [%s], some of copied files may still exist", + GetErrorString(errno).c_str()); + } error_cb(FilesystemError::Other); return; } if (0 != remove(oldPath.c_str())) { LoggerE("Error while removing file [%s]", GetErrorString(errno).c_str()); - remove(newPath.c_str()); + if (0 != remove(newPath.c_str())) { + LoggerW("Error during rollback [%s], some of copied files may still exist", + GetErrorString(errno).c_str()); + } error_cb(FilesystemError::Other); return; }