From 8ba1a37ea744a18138717da3bb40c3c56da2a7f7 Mon Sep 17 00:00:00 2001 From: Roland Winklmeier Date: Sun, 28 Sep 2014 13:06:58 +0200 Subject: [PATCH] Fix warning detected by gcc 4.9.1 - unused variables - linker error with the MinGW DX SDK - don't delete a void* pointer - initialization order --- src/plugins/simulator/fs9/lobby_client.cpp | 11 +++++++++-- src/plugins/simulator/fs9/plugin_fs9.pro | 2 +- src/plugins/simulator/fs9/simulator_fs9.cpp | 5 ++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/plugins/simulator/fs9/lobby_client.cpp b/src/plugins/simulator/fs9/lobby_client.cpp index 6cb1780d4..2da80ce4d 100644 --- a/src/plugins/simulator/fs9/lobby_client.cpp +++ b/src/plugins/simulator/fs9/lobby_client.cpp @@ -204,8 +204,12 @@ namespace BlackSimPlugin SafeDeleteArray(pSettings->pwszPlayerName); SafeDeleteArray(pSettings->dpnAppDesc.pwszSessionName); SafeDeleteArray(pSettings->dpnAppDesc.pwszPassword); - SafeDeleteArray(pSettings->dpnAppDesc.pvReservedData); - SafeDeleteArray(pSettings->dpnAppDesc.pvApplicationReservedData); + + // The following two lines came from DX9 SDK samples, but they don't make sense. + // Deleteing a void* pointer is considered unsafe. If you really had to pass + // anything non-void here, make sure the original object is cleaned up properly. + // SafeDeleteArray(pSettings->dpnAppDesc.pvReservedData); + // SafeDeleteArray(pSettings->dpnAppDesc.pvApplicationReservedData); SafeRelease(pSettings->pdp8HostAddress); SafeRelease(pSettings->ppdp8DeviceAddresses[0]); SafeDeleteArray(pSettings->ppdp8DeviceAddresses); @@ -225,6 +229,7 @@ namespace BlackSimPlugin { PDPL_MESSAGE_DISCONNECT pDisconnectMsg; pDisconnectMsg = (PDPL_MESSAGE_DISCONNECT)msgBuffer; + Q_UNUSED(pDisconnectMsg) // We should free any data associated with the // app here, but there is none. @@ -235,6 +240,7 @@ namespace BlackSimPlugin { PDPL_MESSAGE_RECEIVE pReceiveMsg; pReceiveMsg = (PDPL_MESSAGE_RECEIVE)msgBuffer; + Q_UNUSED(pReceiveMsg) // The lobby app sent us data. This sample doesn't // expected data from the app, but it is useful @@ -275,6 +281,7 @@ namespace BlackSimPlugin { PDPL_MESSAGE_CONNECTION_SETTINGS pConnectionStatusMsg; pConnectionStatusMsg = (PDPL_MESSAGE_CONNECTION_SETTINGS)msgBuffer; + Q_UNUSED(pConnectionStatusMsg) // The app has changed the connection settings. // This simple client doesn't handle this, but more complex clients may diff --git a/src/plugins/simulator/fs9/plugin_fs9.pro b/src/plugins/simulator/fs9/plugin_fs9.pro index 27ae18be5..13da91d11 100644 --- a/src/plugins/simulator/fs9/plugin_fs9.pro +++ b/src/plugins/simulator/fs9/plugin_fs9.pro @@ -9,7 +9,7 @@ TEMPLATE = lib CONFIG += plugin shared CONFIG += blackmisc blackcore blacksim -LIBS += -lsimulator_fscommon -lFSUIPC_User +LIBS += -lsimulator_fscommon -lFSUIPC_User -luuid # required for FSUIPC win32:!win32-g++*: QMAKE_LFLAGS += /NODEFAULTLIB:LIBC.lib diff --git a/src/plugins/simulator/fs9/simulator_fs9.cpp b/src/plugins/simulator/fs9/simulator_fs9.cpp index 0275892d5..6499938b8 100644 --- a/src/plugins/simulator/fs9/simulator_fs9.cpp +++ b/src/plugins/simulator/fs9/simulator_fs9.cpp @@ -44,8 +44,8 @@ namespace BlackSimPlugin ISimulator(parent), m_fs9Host(new CFs9Host), m_hostThread(this), - m_simulatorInfo(CSimulatorInfo::FS9()), m_lobbyClient(new CLobbyClient(this)), + m_simulatorInfo(CSimulatorInfo::FS9()), m_fsuipc(new FsCommon::CFsuipc()) { // We move the host thread already in the constructor @@ -332,7 +332,10 @@ namespace BlackSimPlugin m_fs9ClientThreads.remove(client); m_hashFs9Clients.remove(callsign); + break; } + default: + break; } }