Fix casting from and to void* 99/37199/1
authorLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Fri, 20 Mar 2015 14:09:25 +0000 (15:09 +0100)
committerLukasz Wojciechowski <l.wojciechow@partner.samsung.com>
Fri, 20 Mar 2015 14:09:25 +0000 (15:09 +0100)
There were some places, where reinterpret_cast was used to cast
from or to void* type. This breaks C++ standard.
Fix replaces reinterpret_cast with static_cast.

Change-Id: I9bc5aa3307ce0b0fef4a988d14d06b01f290b853

src/common/service_manager.cpp
src/cynara-tests/common/cynara_test_agent_request.cpp
src/cynara-tests/common/cynara_test_client_async_client.cpp
src/cynara-tests/common/cynara_test_client_async_request_monitor.cpp
src/cynara-tests/common/cynara_test_client_async_status_monitor.cpp

index 7321f77..5349171 100644 (file)
@@ -54,7 +54,7 @@ ServiceManager::ServiceManager(const std::string &serviceName)
     addBusMatch(MATCH_RELOADING);
     m_connection.flush();
     m_connection.addFilter(messageHandler,
-                           reinterpret_cast<void*>(this));
+                           static_cast<void*>(this));
     subscribeSignals();
     m_connection.requestName(DBUS_CLIENT_NAME);
     getUnitPath();
@@ -190,7 +190,7 @@ void ServiceManager::sendResetFailedToService()
 DBusHandlerResult ServiceManager::messageHandler(DBusConnection *conn, DBusMessage *msg, void *t)
 {
     (void) conn;
-    ServiceManager* self = reinterpret_cast<ServiceManager*>(t);
+    ServiceManager* self = static_cast<ServiceManager*>(t);
 
     DBus::MessageIn messageIn(msg, true);
     if (messageIn.isSignal(SYSTEMD_MANAGER_INTERFACE, MATCH_JOB_REMOVED))
index 52cb46a..821624e 100644 (file)
@@ -39,7 +39,7 @@ void AgentRequest::set(cynara_agent_msg_type type, cynara_agent_req_id id,
 {
     m_type = type;
     m_id = id;
-    m_data = Cynara::PluginData(reinterpret_cast<const char*>(data), dataSize);
+    m_data = Cynara::PluginData(static_cast<const char*>(data), dataSize);
     m_client.clear();
     m_user.clear();
     m_privilege.clear();
index 3de731a..6c70813 100644 (file)
@@ -55,7 +55,7 @@ Client::Client(const StatusFunction &userFunction)
     int ret;
     RUNNER_DEFER_SCOPE(ret = cynara_async_initialize(&m_cynara, nullptr,
                                                      StatusMonitor::updateStatus,
-                                                     reinterpret_cast<void*>(&m_statusMonitor)););
+                                                     static_cast<void*>(&m_statusMonitor)););
     RUNNER_ASSERT_MSG(ret == CYNARA_API_SUCCESS,
                          "cynara_async_initialize() failed. ret = " << ret << ".");
     RUNNER_ASSERT_MSG(m_cynara != nullptr, "cynara_async struct was not initialized.");
@@ -111,7 +111,7 @@ void Client::createRequest(const CheckData &checkData, cynara_check_id &id,
                                                          checkData.m_user.c_str(),
                                                          checkData.m_privilege.c_str(), &id,
                                                          RequestMonitor::updateResponse,
-                                                         reinterpret_cast<void*>(
+                                                         static_cast<void*>(
                                                              &m_requestMonitor)););
     if (ret == CYNARA_API_SUCCESS)
         m_requestMonitor.registerRequest(id, callbackData);
index 3827797..33244d0 100644 (file)
@@ -54,7 +54,7 @@ void RequestMonitor::updateResponse(cynara_check_id checkId, cynara_async_call_c
                                     int response, void *data)
 {
     RUNNER_DEFER_TRYCATCH(
-        RequestMonitor *monitor = reinterpret_cast<RequestMonitor*>(data);
+        RequestMonitor *monitor = static_cast<RequestMonitor*>(data);
         if (!monitor) {
             RUNNER_FAIL_MSG("Bad user data (nullptr) in response callback.");
             return;
index 37e3f3c..5246178 100644 (file)
@@ -28,7 +28,7 @@ StatusMonitor::StatusMonitor(const StatusFunction &userFunction)
 void StatusMonitor::updateStatus(int oldFd, int newFd, cynara_async_status status, void *data)
 {
     RUNNER_DEFER_TRYCATCH(
-        StatusMonitor *monitor = reinterpret_cast<StatusMonitor*>(data);
+        StatusMonitor *monitor = static_cast<StatusMonitor*>(data);
         if (!monitor) {
             RUNNER_FAIL_MSG("Bad user data (nullptr) in status callback.");
             return;