diff --git a/telldus-core/common/Strings.cpp b/telldus-core/common/Strings.cpp index 29aca4a6..d29ee203 100644 --- a/telldus-core/common/Strings.cpp +++ b/telldus-core/common/Strings.cpp @@ -50,7 +50,7 @@ std::wstring TelldusCore::charToWstring(const char *value) { strcpy(inString, value); // Create buffer for output - char *outString = (char*)new wchar_t[utf8Length+1]; + char *outString = reinterpret_cast(new wchar_t[utf8Length+1]); memset(outString, 0, sizeof(wchar_t)*(utf8Length+1)); #ifdef _FREEBSD @@ -64,7 +64,7 @@ std::wstring TelldusCore::charToWstring(const char *value) { iconv(convDesc, &inPointer, &utf8Length, &outPointer, &outbytesLeft); iconv_close(convDesc); - std::wstring retval( (wchar_t *)outString ); + std::wstring retval( reinterpret_cast(outString) ); // Cleanup delete[] inString; @@ -191,7 +191,7 @@ std::string TelldusCore::wideToString(const std::wstring &input) { size_t outbytesLeft = wideSize+sizeof(char); // NOLINT(runtime/sizeof) // Copy the instring - char *inString = (char*)new wchar_t[input.length()+1]; + char *inString = reinterpret_cast(new wchar_t[input.length()+1]); memcpy(inString, input.c_str(), wideSize+sizeof(wchar_t)); // Create buffer for output @@ -233,7 +233,7 @@ std::string TelldusCore::sformatf(const char *format, va_list ap) { int size = 100; /* Guess we need no more than 100 bytes. */ char *p, *np; - if ((p = (char*)malloc(size)) == NULL) { + if ((p = reinterpret_cast(malloc(size))) == NULL) { return ""; } @@ -255,7 +255,7 @@ std::string TelldusCore::sformatf(const char *format, va_list ap) { } else { /* glibc 2.0 */ size *= 2; /* twice the old size */ } - if ((np = (char *)realloc (p, size)) == NULL) { + if ((np = reinterpret_cast(realloc (p, size))) == NULL) { free(p); return ""; } else { diff --git a/telldus-core/common/common.h b/telldus-core/common/common.h index bbb0a783..6ead6c8b 100644 --- a/telldus-core/common/common.h +++ b/telldus-core/common/common.h @@ -58,7 +58,7 @@ inline void debuglog(const int intMessage, const std::string strMessage) { #elif !defined(_MACOSX) && !defined(__FreeBSD__) pthread_t thread = pthread_self(); - printf("[%i] %i - %s\n", (int)thread, intMessage, strMessage.c_str()); + printf("[%i] %i - %s\n", static_cast(thread), intMessage, strMessage.c_str()); fflush(stdout); #else printf("%i - %s\n", intMessage, strMessage.c_str()); @@ -67,10 +67,10 @@ inline void debuglog(const int intMessage, const std::string strMessage) { inline char *wrapStdString( const std::string &string) { #ifdef _WINDOWS - return (char *)SysAllocStringByteLen(string.c_str(), (unsigned int)string.size()); + return reinterpret_cast(SysAllocStringByteLen(string.c_str(), (unsigned int)string.size())); #else char *returnVal; - returnVal = (char *)malloc(sizeof(*returnVal) * (string.size()+1)); + returnVal = reinterpret_cast(malloc(sizeof(*returnVal) * (string.size()+1))); strcpy(returnVal, string.c_str()); return returnVal; #endif diff --git a/telldus-core/service/ControllerManager.cpp b/telldus-core/service/ControllerManager.cpp index 977ff598..b1ce2ce1 100644 --- a/telldus-core/service/ControllerManager.cpp +++ b/telldus-core/service/ControllerManager.cpp @@ -265,7 +265,7 @@ std::wstring ControllerManager::getControllers() const { TelldusCore::Message msg; - msg.addArgument((int)d->controllers.size()); + msg.addArgument(static_cast(d->controllers.size())); for(ControllerMap::iterator it = d->controllers.begin(); it != d->controllers.end(); ++it) { msg.addArgument(it->first); diff --git a/telldus-core/service/DeviceManager.cpp b/telldus-core/service/DeviceManager.cpp index 902145a9..f17cc5a5 100644 --- a/telldus-core/service/DeviceManager.cpp +++ b/telldus-core/service/DeviceManager.cpp @@ -318,7 +318,7 @@ int DeviceManager::setDeviceProtocol(int deviceId, const std::wstring &protocol) int DeviceManager::getNumberOfDevices() { TelldusCore::MutexLocker deviceListLocker(&d->lock); - return (int)d->devices.size(); + return static_cast(d->devices.size()); } int DeviceManager::addDevice() { @@ -582,7 +582,7 @@ std::wstring DeviceManager::getSensors() const { TelldusCore::Message msg; - msg.addArgument((int)d->sensorList.size()); + msg.addArgument(static_cast(d->sensorList.size())); for (std::list::iterator it = d->sensorList.begin(); it != d->sensorList.end(); ++it) { TelldusCore::MutexLocker sensorLocker(*it); @@ -621,7 +621,7 @@ std::wstring DeviceManager::getSensorValue(const std::wstring &protocol, const s std::string value = sensor->value(dataType); if (value.length() > 0) { msg.addArgument(TelldusCore::charToWstring(value.c_str())); - msg.addArgument((int)sensor->timestamp()); + msg.addArgument(static_cast(sensor->timestamp())); } return msg; } @@ -714,7 +714,7 @@ void DeviceManager::setSensorValueAndSignal( const std::string &dataType, int da eventData->sensorId = sensor->id(); eventData->dataType = dataTypeId; eventData->value = TelldusCore::charToWstring(sensor->value(dataTypeId).c_str()); - eventData->timestamp = (int)timestamp; + eventData->timestamp = static_cast(timestamp); d->deviceUpdateEvent->signal(eventData); } diff --git a/telldus-core/service/Log.cpp b/telldus-core/service/Log.cpp index 91ad5b95..13281c59 100644 --- a/telldus-core/service/Log.cpp +++ b/telldus-core/service/Log.cpp @@ -162,16 +162,16 @@ void Log::message(Log::LogLevel logLevel, const char *format, va_list ap) const switch (logLevel) { case Debug: - ReportEvent(d->eventSource, EVENTLOG_SUCCESS, NULL, LOG_DEBUG, NULL, 1, 0, (LPCWSTR*)pInsertStrings, NULL); + ReportEvent(d->eventSource, EVENTLOG_SUCCESS, NULL, LOG_DEBUG, NULL, 1, 0, reinterpret_cast(pInsertStrings), NULL); break; case Notice: - ReportEvent(d->eventSource, EVENTLOG_INFORMATION_TYPE, NULL, LOG_NOTICE, NULL, 1, 0, (LPCWSTR*)pInsertStrings, NULL); + ReportEvent(d->eventSource, EVENTLOG_INFORMATION_TYPE, NULL, LOG_NOTICE, NULL, 1, 0, reinterpret_cast(pInsertStrings), NULL); break; case Warning: - ReportEvent(d->eventSource, EVENTLOG_WARNING_TYPE, NULL, LOG_WARNING, NULL, 1, 0, (LPCWSTR*)pInsertStrings, NULL); + ReportEvent(d->eventSource, EVENTLOG_WARNING_TYPE, NULL, LOG_WARNING, NULL, 1, 0, reinterpret_cast(pInsertStrings), NULL); break; case Error: - ReportEvent(d->eventSource, EVENTLOG_ERROR_TYPE, NULL, LOG_ERR, NULL, 1, 0, (LPCWSTR*)pInsertStrings, NULL); + ReportEvent(d->eventSource, EVENTLOG_ERROR_TYPE, NULL, LOG_ERR, NULL, 1, 0, reinterpret_cast(pInsertStrings), NULL); break; } #endif diff --git a/telldus-core/service/ProtocolFineoffset.cpp b/telldus-core/service/ProtocolFineoffset.cpp index daa3635e..c4daca58 100644 --- a/telldus-core/service/ProtocolFineoffset.cpp +++ b/telldus-core/service/ProtocolFineoffset.cpp @@ -38,7 +38,7 @@ std::string ProtocolFineoffset::decodeData(const ControllerMessage &dataMsg) { retString << "class:sensor;protocol:fineoffset;id:" << id << ";model:"; if (humidity <= 100) { - retString << "temperaturehumidity;humidity:" << (int)humidity << ";"; + retString << "temperaturehumidity;humidity:" << static_cast(humidity) << ";"; } else if (humidity == 0xFF) { retString << "temperature;"; } else { diff --git a/telldus-core/service/ProtocolMandolyn.cpp b/telldus-core/service/ProtocolMandolyn.cpp index 555f67d0..1f5f3155 100644 --- a/telldus-core/service/ProtocolMandolyn.cpp +++ b/telldus-core/service/ProtocolMandolyn.cpp @@ -18,7 +18,7 @@ std::string ProtocolMandolyn::decodeData(const ControllerMessage &dataMsg) { bool parity = value & 0x1; value >>= 1; - double temp = (double)(value & 0x7FFF) - (double)6400; + double temp = static_cast(value & 0x7FFF) - static_cast(6400); temp = temp/128.0; value >>= 15; @@ -38,7 +38,7 @@ std::string ProtocolMandolyn::decodeData(const ControllerMessage &dataMsg) { << house*10+channel << ";model:temperaturehumidity;" << "temp:" << std::fixed << std::setprecision(1) << temp - << ";humidity:" << (int)humidity << ";"; + << ";humidity:" << static_cast(humidity) << ";"; return retString.str(); } diff --git a/telldus-core/service/ProtocolNexa.cpp b/telldus-core/service/ProtocolNexa.cpp index daa91560..3965b2b7 100644 --- a/telldus-core/service/ProtocolNexa.cpp +++ b/telldus-core/service/ProtocolNexa.cpp @@ -167,7 +167,7 @@ std::string ProtocolNexa::getStringSelflearningForCode(int intHouse, int intCode std::string ProtocolNexa::decodeData(const ControllerMessage& dataMsg) { uint32_t allData = 0; - sscanf(dataMsg.getParameter("data").c_str(), "%lx", (long*)&allData); // NOLINT(runtime/int) + sscanf(dataMsg.getParameter("data").c_str(), "%lx", reinterpret_cast(&allData)); // NOLINT(runtime/int) if(TelldusCore::comparei(dataMsg.model(), L"selflearning")) { // selflearning @@ -247,7 +247,7 @@ std::string ProtocolNexa::decodeDataCodeSwitch(uint32_t allData) { } std::stringstream retString; - retString << "class:command;protocol:arctech;model:codeswitch;house:" << char(house); + retString << "class:command;protocol:arctech;model:codeswitch;house:" << static_cast(house); if(method == 6) { retString << ";unit:" << unit << ";method:turnoff;"; diff --git a/telldus-core/service/ProtocolOregon.cpp b/telldus-core/service/ProtocolOregon.cpp index 062c33af..b1eedb6b 100644 --- a/telldus-core/service/ProtocolOregon.cpp +++ b/telldus-core/service/ProtocolOregon.cpp @@ -63,7 +63,7 @@ std::string ProtocolOregon::decodeEA4C(const std::string &data) { } std::stringstream retString; - retString << "class:sensor;protocol:oregon;model:EA4C;id:" << (int)address + retString << "class:sensor;protocol:oregon;model:EA4C;id:" << static_cast(address) << ";temp:" << std::fixed << std::setprecision(1) << temperature << ";"; return retString.str(); @@ -114,7 +114,7 @@ std::string ProtocolOregon::decode1A2D(const std::string &data) { } std::stringstream retString; - retString << "class:sensor;protocol:oregon;model:1A2D;id:" << (int)address + retString << "class:sensor;protocol:oregon;model:1A2D;id:" << static_cast(address) << ";temp:" << std::fixed << std::setprecision(1) << temperature << ";"; return retString.str(); diff --git a/telldus-core/service/ProtocolWaveman.cpp b/telldus-core/service/ProtocolWaveman.cpp index 77a7a1bf..50d4985d 100644 --- a/telldus-core/service/ProtocolWaveman.cpp +++ b/telldus-core/service/ProtocolWaveman.cpp @@ -30,7 +30,7 @@ std::string ProtocolWaveman::decodeData(const ControllerMessage& dataMsg) { unsigned int unit = 0; unsigned int method = 0; - sscanf(dataMsg.getParameter("data").c_str(), "%lx", (long*)&allData); // NOLINT(runtime/int) + sscanf(dataMsg.getParameter("data").c_str(), "%lx", reinterpret_cast(&allData)); // NOLINT(runtime/int) method = allData & 0xF00; method >>= 8; @@ -59,7 +59,7 @@ std::string ProtocolWaveman::decodeData(const ControllerMessage& dataMsg) { } std::stringstream retString; - retString << "class:command;protocol:waveman;model:codeswitch;house:" << char(house); + retString << "class:command;protocol:waveman;model:codeswitch;house:" << static_cast(house); if(method == 0) { retString << ";unit:" << unit << ";method:turnoff;"; diff --git a/telldus-core/service/ProtocolX10.cpp b/telldus-core/service/ProtocolX10.cpp index a5883627..ea8d1b9c 100644 --- a/telldus-core/service/ProtocolX10.cpp +++ b/telldus-core/service/ProtocolX10.cpp @@ -167,7 +167,7 @@ std::string ProtocolX10::decodeData(const ControllerMessage& dataMsg) { std::stringstream retString; retString << "class:command;protocol:x10;model:codeswitch;"; - retString << "house:" << (char)('A' + intHouse); + retString << "house:" << static_cast('A' + intHouse); retString << ";unit:" << unit+1; retString << ";method:"; if(method == 0) { diff --git a/telldus-core/service/TellStick_libftdi.cpp b/telldus-core/service/TellStick_libftdi.cpp index 9cc3de19..8ce36700 100644 --- a/telldus-core/service/TellStick_libftdi.cpp +++ b/telldus-core/service/TellStick_libftdi.cpp @@ -201,7 +201,7 @@ int TellStick::send( const std::string &strMessage ) { if(ret < 0) { c = false; } else if(ret != strMessage.length()) { - Log::debug("Weird send length? retval %i instead of %d\n", ret, (int)strMessage.length()); + Log::debug("Weird send length? retval %i instead of %d\n", ret, static_cast(strMessage.length())); } delete[] tempMessage;