Use int16/int64/etc, rather than the C types according to Google style guidelines "runtime/int"

This commit is contained in:
Micke Prag 2012-06-08 16:45:39 +02:00
parent 6666dc0294
commit 3dcc7a04ba
4 changed files with 12 additions and 9 deletions

View file

@ -165,9 +165,9 @@ std::string ProtocolNexa::getStringSelflearningForCode(int intHouse, int intCode
} }
std::string ProtocolNexa::decodeData(ControllerMessage& dataMsg) { std::string ProtocolNexa::decodeData(ControllerMessage& dataMsg) {
unsigned long allData = 0; uint32_t allData = 0;
sscanf(dataMsg.getParameter("data").c_str(), "%lx", &allData); sscanf(dataMsg.getParameter("data").c_str(), "%lx", (long*)&allData); // NOLINT(runtime/int)
if(TelldusCore::comparei(dataMsg.model(), L"selflearning")) { if(TelldusCore::comparei(dataMsg.model(), L"selflearning")) {
// selflearning // selflearning
@ -179,7 +179,7 @@ std::string ProtocolNexa::decodeData(ControllerMessage& dataMsg) {
} }
} }
std::string ProtocolNexa::decodeDataSelfLearning(long allData) { std::string ProtocolNexa::decodeDataSelfLearning(uint32_t allData) {
unsigned int house = 0; unsigned int house = 0;
unsigned int unit = 0; unsigned int unit = 0;
unsigned int group = 0; unsigned int group = 0;
@ -218,7 +218,7 @@ std::string ProtocolNexa::decodeDataSelfLearning(long allData) {
return retString.str(); return retString.str();
} }
std::string ProtocolNexa::decodeDataCodeSwitch(long allData) { std::string ProtocolNexa::decodeDataCodeSwitch(uint32_t allData) {
unsigned int house = 0; unsigned int house = 0;
unsigned int unit = 0; unsigned int unit = 0;
unsigned int method = 0; unsigned int method = 0;

View file

@ -7,6 +7,7 @@
#ifndef TELLDUS_CORE_SERVICE_PROTOCOLNEXA_H_ #ifndef TELLDUS_CORE_SERVICE_PROTOCOLNEXA_H_
#define TELLDUS_CORE_SERVICE_PROTOCOLNEXA_H_ #define TELLDUS_CORE_SERVICE_PROTOCOLNEXA_H_
#include <stdint.h>
#include <string> #include <string>
#include "service/ControllerMessage.h" #include "service/ControllerMessage.h"
#include "service/Device.h" #include "service/Device.h"
@ -27,8 +28,8 @@ protected:
private: private:
static int lastArctecCodeSwitchWasTurnOff; static int lastArctecCodeSwitchWasTurnOff;
static std::string decodeDataCodeSwitch(long allData); static std::string decodeDataCodeSwitch(uint32_t allData);
static std::string decodeDataSelfLearning(long allData); static std::string decodeDataSelfLearning(uint32_t allData);
}; };
#endif // TELLDUS_CORE_SERVICE_PROTOCOLNEXA_H_ #endif // TELLDUS_CORE_SERVICE_PROTOCOLNEXA_H_

View file

@ -5,6 +5,7 @@
// //
// //
#include "service/ProtocolSartano.h" #include "service/ProtocolSartano.h"
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <sstream> #include <sstream>
#include <string> #include <string>
@ -51,7 +52,7 @@ std::string ProtocolSartano::decodeData(ControllerMessage &dataMsg) {
sscanf(data.c_str(), "%X", &allDataIn); sscanf(data.c_str(), "%X", &allDataIn);
unsigned long mask = (1<<11); uint16_t mask = (1<<11);
for(int i = 0; i < 12; ++i) { for(int i = 0; i < 12; ++i) {
allData >>= 1; allData >>= 1;
if((allDataIn & mask) == 0) { if((allDataIn & mask) == 0) {

View file

@ -5,6 +5,7 @@
// //
// //
#include "service/ProtocolWaveman.h" #include "service/ProtocolWaveman.h"
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <sstream> #include <sstream>
#include <string> #include <string>
@ -24,12 +25,12 @@ std::string ProtocolWaveman::getOffCode() const {
} }
std::string ProtocolWaveman::decodeData(ControllerMessage& dataMsg) { std::string ProtocolWaveman::decodeData(ControllerMessage& dataMsg) {
unsigned long allData = 0; uint32_t allData = 0;
unsigned int house = 0; unsigned int house = 0;
unsigned int unit = 0; unsigned int unit = 0;
unsigned int method = 0; unsigned int method = 0;
sscanf(dataMsg.getParameter("data").c_str(), "%lx", &allData); sscanf(dataMsg.getParameter("data").c_str(), "%lx", (long*)&allData); // NOLINT(runtime/int)
method = allData & 0xF00; method = allData & 0xF00;
method >>= 8; method >>= 8;