Permalink
Browse files

fix Coverity issues

:Release Notes:
Fix Coverity issues

:Detailed Notes:
Fix unchecked return values: 10895-10899, 44080
Fix Unsigned compare against 0: 17729
Fix Unintialized scalar field: 38173-38174

:Testing Performed:
Built image, tested that normal configurator functionality works

:QA Notes:

:Issues Addressed:
[GF-53844] Fix coverity issues in configurator

Open-webOS-DCO-1.0-Signed-off-by: Eric Blade <eric.blade@lge.com>

Change-Id: Iba1838b0cd6778550a233293f91fdfde4496ebe4
Reviewed-on: https://g2g.palm.com/4465
Reviewed-by: DCO Verification
Reviewed-by: Eric Blade <eric.blade@lge.com>
Tested-by: Eric Blade <eric.blade@lge.com>
Reviewed-by: Maksym Sditanov <maxim.sditanov@lge.com>
  • Loading branch information...
ericblade authored and Maksym Sditanov committed Jan 23, 2014
1 parent 5bfd131 commit 18ebce9af19d635b9c8765c7165d2ac2e7b007d0
Showing with 22 additions and 13 deletions.
  1. +10 −5 src/BusClient.cpp
  2. +4 −2 src/Configurator.cpp
  3. +2 −1 src/DbKindConfigurator.cpp
  4. +2 −1 src/DbPermissionsConfigurator.cpp
  5. +3 −4 src/FileCacheConfigurator.cpp
  6. +1 −0 src/Log.h
View
@@ -721,18 +721,23 @@ void BusClient::ScheduleShutdown()
if (m_wrongAplication) {
MojString response;
- response.appendFormat("Aplication or service doesn't exist");
+ response.appendFormat("Application or service doesn't exist");
m_wrongAplication = false;
- m_msg->replyError(MojErrInternal, response.data());
-
+ if(m_msg->replyError(MojErrInternal, response.data()) != MojErrNone) {
+ LOG_WARNING(MSGID_SHUTDOWN_ERROR, 1, PMLOGKS("Response", response.data()), "Application or service doesn't exist");
+ }
} else if (!failed.empty()) {
MojString response;
response.appendFormat("Partial configuration - %zu ok, %zu failed", ok.size(), failed.size());
- m_msg->replyError(MojErrInternal, response.data());
+ if(m_msg->replyError(MojErrInternal, response.data()) != MojErrNone) {
+ LOG_WARNING(MSGID_SHUTDOWN_ERROR, 1, PMLOGKS("Response", response.data()), "Partial configuration");
+ }
} else {
MojObject response;
response.putInt("configured", ok.size());
- m_msg->replySuccess(response);
+ if(m_msg->replySuccess(response) != MojErrNone) {
+ LOG_WARNING(MSGID_SHUTDOWN_ERROR, 0, "Configured");
+ }
}
m_msg.reset();
}
View
@@ -50,7 +50,8 @@ ConfiguratorCallback::ConfiguratorCallback(Configurator* configurator, const std
m_handler(configurator),
m_delegateInvoked(false),
m_unconfigure(false),
- m_configure(false)
+ m_configure(false),
+ m_defaultCacheBehaviourUsed(false)
{
assert(m_handler.get() != NULL);
}
@@ -148,7 +149,8 @@ Configurator::Configurator(const string& id, ConfigType confType, RunType type,
m_currentType(type),
m_completed(false),
m_configDir(configDirectory),
- m_scanned(false)
+ m_scanned(false),
+ m_emptyConfigurator(false)
{
InitCacheDir();
}
@@ -81,7 +81,8 @@ MojErr DbKindConfigurator::CheckOwner(const std::string& filePath, MojObject &pa
} else {
LOG_DEBUG("setting owner for %s (%s)", filePath.c_str(), ownerid.c_str());
}
- params.putString("owner", ownerid.c_str());
+ MojErr err = params.putString("owner", ownerid.c_str());
+ MojErrCheck(err);
} else {
// todo - return error once we disallow deprecated usage
// an owner should always be available as a property of the filePath
@@ -57,7 +57,8 @@ MojErr DbPermissionsConfigurator::ProcessConfig(const string& filePath, MojObjec
MojObject perms;
owner = ParentId(filePath);
- perms.put("permissions", permissions);
+ MojErr err = perms.put("permissions", permissions);
+ MojErrCheck(err);
// for third-party packages, we set the appid on the service request
// so that mojodb does things correctly. root config files aren't split up
@@ -29,8 +29,7 @@ const char* const FileCacheConfigurator::FILECACHE_TYPENAME_KEY = "typeName";
static bool endsWith(const std::string& str, const std::string &suffix)
{
- size_t toSearch = str.length() - suffix.length();
- return toSearch >= 0 && string::npos != str.rfind(suffix, toSearch);
+ return str.length() >= suffix.length() && string::npos != str.rfind(suffix, str.length() - suffix.length());
}
class FileCacheConfiguratorResponse : public ConfiguratorCallback {
@@ -70,9 +69,9 @@ class FileCacheConfiguratorResponse : public ConfiguratorCallback {
MojErr Response(MojObject& response, MojErr err)
{
bool success = true;
- response.get("returnValue", success);
+ bool getSuccess = response.get("returnValue", success);
- if (err || !success) {
+ if (err || !getSuccess || !success) {
// unfortunately file cache doesn't use regular C++ mojo error codes
// & more unfortunately all the various failure reasons for define are hidden
// behind 1 error code
View
@@ -38,6 +38,7 @@ PMLOG_TRACE(__VA_ARGS__);
#define MSGID_DB_KIND_CONFIG_ERROR "DB_KIND_CONFIG_ERROR"
#define MSGID_CONFIGURATOR_WARNING "CONFIGURATOR_WARNING"
#define MSGID_CONFIGURATOR_ERROR "CONFIGURATOR_ERROR"
+#define MSGID_SHUTDOWN_ERROR "SHUTDOWN_ERROR"
extern PmLogContext getactivitymanagercontext();

0 comments on commit 18ebce9

Please sign in to comment.