Removing warnings from modules: badge, bluetooth, calendar.
authorAnna Niznik <a.niznik@samsung.com>
Tue, 21 Jul 2015 11:56:38 +0000 (13:56 +0200)
committerPawel Sikorski <p.sikorski@samsung.com>
Mon, 3 Aug 2015 13:26:01 +0000 (22:26 +0900)
Using cppcheck (with --enable=all flag).
[calendar] Also used gcc.

[Verification] TCT result:
Before:
[badge]     100.00%
[bluetooth] 76.78%
[calendar]  100.00%
After:
[badge]     100.00%
[bluetooth] 76.78%
[calendar]  100.00%

Change-Id: I114b76348b70462d8f386d6f0bce5369b1b3318f
Signed-off-by: Anna Niznik <a.niznik@samsung.com>
src/bluetooth/bluetooth_adapter.cc
src/bluetooth/bluetooth_gatt_service.cc
src/calendar/calendar.cc
src/calendar/calendar_record.cc

index 0151b84bc931162a83307b3146f7f6213883208d..c61648b4b7739f62c942925283ace424cb109f4f 100755 (executable)
@@ -347,6 +347,8 @@ BluetoothAdapter::BluetoothAdapter(BluetoothInstance& instance) :
     is_powered_(false),
     is_initialized_(false),
     user_request_list_(),
+    user_request_callback_(),
+    requested_powered_(),
     instance_(instance)
 {
   LoggerD("Entered");
@@ -1280,9 +1282,9 @@ void BluetoothAdapter::UnregisterUUID(const std::string& uuid, int callback_hand
       }
     }
 
-    if (registered_uuids_.size() == 0 &&
-        connection_requests_.size() == 0 &&
-        connected_sockets_.size() == 0) {
+    if (registered_uuids_.empty() &&
+        connection_requests_.empty() &&
+        connected_sockets_.empty()) {
       bt_socket_unset_connection_state_changed_cb();
     }
   } else if (result.IsSuccess()){
@@ -1466,13 +1468,13 @@ void BluetoothAdapter::OnSocketConnected(
     return;
   }
 
-  if (object->connected_sockets_.size() == 0) {
+  if (object->connected_sockets_.empty()) {
     bt_socket_unset_data_received_cb();
   }
 
-  if (object->registered_uuids_.size() == 0 &&
-      object->connection_requests_.size() == 0 &&
-      object->connected_sockets_.size() == 0) {
+  if (object->registered_uuids_.empty() &&
+      object->connection_requests_.empty() &&
+      object->connected_sockets_.empty()) {
     bt_socket_unset_connection_state_changed_cb();
   }
 }
index d4c29e559db388f013ac10465478209cfacecd25..738a87c6fc1c6ff9e95108a3cb7fcb7b0df8be1e 100755 (executable)
@@ -322,7 +322,7 @@ void BluetoothGATTService::ReadValue(const picojson::value& args,
   bt_gatt_h handle = (bt_gatt_h) static_cast<long>(args.get("handle").get<double>());
 
   auto read_value = [](int result, bt_gatt_h handle, void *user_data) -> void {
-    Data* data = (Data*) user_data;
+    Data* data = static_cast<Data*>(user_data);
     double callback_handle = data->callback_handle;
     BluetoothGATTService* service = data->service;
     delete data;
index 5998e55de87b645174f94822cc67515c1e7cef6a..c28a8fe216aa60072f55596314b345e884ee8612 100755 (executable)
@@ -342,7 +342,7 @@ PlatformResult Calendar::UpdateBatch(const picojson::object& args,
   }
   CalendarListPtr list_ptr = CalendarListPtr(list, CalendarRecord::ListDeleter);
 
-  int ret, id;
+  int id;
   calendar_record_h record;
 
   for (auto& item : items) {
@@ -353,7 +353,7 @@ PlatformResult Calendar::UpdateBatch(const picojson::object& args,
       id = common::stol(FromJson<std::string>(item_obj, "id"));
     }
 
-    ret = calendar_db_get_record(view_uri.c_str(), id, &record);
+    int ret = calendar_db_get_record(view_uri.c_str(), id, &record);
     if (CALENDAR_ERROR_NONE != ret) {
       LoggerW("Can't get platform record %d", ret);
       return PlatformResult(ErrorCode::UNKNOWN_ERR,
@@ -669,13 +669,16 @@ PlatformResult Calendar::Find(const picojson::object& args, picojson::array& arr
           error_code = calendar_filter_add_int(
               sub_filter, propertyId, CALENDAR_MATCH_GREATER_THAN_OR_EQUAL,
               initial_value_date);
+          if ((status = ErrorChecker(error_code)).IsError()) return status;
 
           error_code = calendar_filter_add_operator(
               sub_filter, CALENDAR_FILTER_OPERATOR_AND);
+          if ((status = ErrorChecker(error_code)).IsError()) return status;
 
           error_code = calendar_filter_add_int(
               sub_filter, propertyId, CALENDAR_MATCH_LESS_THAN_OR_EQUAL,
               end_value_date);
+          if ((status = ErrorChecker(error_code)).IsError()) return status;
 
           error_code = calendar_filter_add_filter(calendar_filter, sub_filter);
           if ((status = ErrorChecker(error_code)).IsError()) return status;
@@ -939,9 +942,8 @@ PlatformResult Calendar::RemoveBatch(const picojson::object& args,
     }
   }
 
-  int ret;
   if (ids_to_remove.size() > 0) {
-    ret = calendar_db_delete_records(view_uri.c_str(), &ids_to_remove[0],
+    int ret = calendar_db_delete_records(view_uri.c_str(), &ids_to_remove[0],
                                      ids_to_remove.size());
 
     if (CALENDAR_ERROR_NONE != ret) {
@@ -969,13 +971,12 @@ PlatformResult Calendar::AddChangeListener(const picojson::object& args,
   const std::string& type = FromJson<std::string>(args, "type");
   const std::string& listener_id = FromJson<std::string>(args, "listenerId");
 
-  int ret;
   if (listeners_registered_.find(type) == listeners_registered_.end()) {
     std::string view_uri;
     PlatformResult status = CalendarRecord::TypeToUri(type, &view_uri);
     if (status.IsError()) return status;
 
-    ret = calendar_db_add_changed_cb(view_uri.c_str(), ChangeCallback, this);
+    int ret = calendar_db_add_changed_cb(view_uri.c_str(), ChangeCallback, this);
     if (CALENDAR_ERROR_NONE != ret) {
       LoggerE("Add calendar change callback error for type %s", type.c_str());
       return PlatformResult(ErrorCode::UNKNOWN_ERR,
@@ -1004,13 +1005,12 @@ PlatformResult Calendar::RemoveChangeListener(const picojson::object& args,
 
   const std::string& type = FromJson<std::string>(args, "type");
 
-  int ret;
   if (listeners_registered_.find(type) != listeners_registered_.end()) {
     std::string view_uri;
     PlatformResult status = CalendarRecord::TypeToUri(type, &view_uri);
     if (status.IsError()) return status;
 
-    ret = calendar_db_remove_changed_cb(view_uri.c_str(), ChangeCallback, this);
+    int ret = calendar_db_remove_changed_cb(view_uri.c_str(), ChangeCallback, this);
     if (CALENDAR_ERROR_NONE != ret) {
       LoggerE("Remove calendar change callback error for type %s",
               type.c_str());
index 49830997221582d04e2cf5e2723f08cd0eb6b43a..81c17953e516642a62f26e008809b4bd23fd317c 100755 (executable)
@@ -355,9 +355,8 @@ PlatformResult CalendarRecord::CalendarToJson(calendar_record_h rec,
     return PlatformResult(ErrorCode::UNKNOWN_ERR, "Calendar record is null");
   }
 
-  int id;
+  int id = 0;
   PlatformResult status = GetInt(rec, _calendar_book.id, &id);
-
   int account_id;
   GetInt(rec, _calendar_book.account_id, &account_id);