Skip to content

Commit

Permalink
Fixed some build warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
grodansparadis committed Oct 17, 2024
1 parent 60b4643 commit b91d641
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 42 deletions.
43 changes: 22 additions & 21 deletions src/vscp/common/mdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2089,7 +2089,7 @@ CMDF::save_xml(const std::string &path)

std::deque<CMDF_Setup *> *pSetupQueue = getSetupObjList();
if ((nullptr != pSetupQueue) && (pSetupQueue->size())) {
size_t pos = 0;
//size_t pos = 0;
for (auto it = pSetupQueue->begin(); it != pSetupQueue->end(); it++) {
CMDF_Setup *pSetup = *it;
fout << "<setup name=\"" << pSetup->getName() << "\" ";
Expand Down Expand Up @@ -2617,7 +2617,7 @@ CMDF::save_json(const std::string &path)
if ((cnt = pManufacturer->getWebObjCount())) {
fout << "," << std::endl;
fout << "\"web\": [" << std::endl;
int i = 0;
size_t i = 0;
while (i < cnt) {
CMDF_Item *pitem = pManufacturer->getWebObj(i);
if (nullptr != pitem) {
Expand All @@ -2640,7 +2640,7 @@ CMDF::save_json(const std::string &path)
if ((cnt = pManufacturer->getSocialObjCount())) {
fout << "," << std::endl;
fout << "\"social\": [" << std::endl;
int i = 0;
size_t i = 0;
while (i < cnt) {
CMDF_Item *pitem = pManufacturer->getSocialObj(i);
if (nullptr != pitem) {
Expand Down Expand Up @@ -2872,10 +2872,10 @@ CMDF::save_json(const std::string &path)
// get pages
std::set<uint16_t> pages;
std::deque<CMDF_Register *> *pregs = getRegisterObjList();
uint32_t nPageCnt = getPages(pages);
//uint32_t nPageCnt = getPages(pages);

// Go throu pages create set/map with sorted registers
int pos = 0;
size_t pos = 0;

// Add registers for page
std::set<uint32_t> regset;
Expand Down Expand Up @@ -2910,7 +2910,7 @@ CMDF::save_json(const std::string &path)
// bits
std::deque<CMDF_Bit *> *pbits = preg->getListBits();
if (pbits->size()) {
int pos = 0;
size_t pos = 0;
fout << "," << std::endl;
fout << "\"bit\": [" << std::endl;
for (auto it = pbits->cbegin(); it != pbits->cend(); ++it) {
Expand All @@ -2930,7 +2930,7 @@ CMDF::save_json(const std::string &path)

std::deque<CMDF_Value *> *pvalues = pbit->getListValues();
if (pvalues->size()) {
int pos = 0;
size_t pos = 0;
fout << "," << std::endl;
fout << "\"valuelist\": [" << std::endl;
for (auto it = pvalues->cbegin(); it != pvalues->cend(); ++it) {
Expand Down Expand Up @@ -2969,7 +2969,7 @@ CMDF::save_json(const std::string &path)

std::deque<CMDF_Value *> *pvalues = preg->getListValues();
if (pvalues->size()) {
int pos = 0;
size_t pos = 0;
fout << "," << std::endl;
fout << "\"valuelist\": [" << std::endl;
for (auto it = pvalues->cbegin(); it != pvalues->cend(); ++it) {
Expand Down Expand Up @@ -3029,7 +3029,7 @@ CMDF::save_json(const std::string &path)
std::deque<CMDF_RemoteVariable *> *prvarList = getRemoteVariableList();

// Go throu pages create set/map with sorted registers
int pos = 0;
size_t pos = 0;

for (auto it = prvarList->cbegin(); it != prvarList->cend(); ++it) {
CMDF_RemoteVariable *prvar = *it;
Expand All @@ -3048,7 +3048,7 @@ CMDF::save_json(const std::string &path)
// bits
std::deque<CMDF_Bit *> *pbits = prvar->getListBits();
if (pbits->size()) {
int pos = 0;
size_t pos = 0;
fout << "," << std::endl;
fout << "\"bit\": [" << std::endl;
for (auto it = pbits->cbegin(); it != pbits->cend(); ++it) {
Expand All @@ -3068,7 +3068,7 @@ CMDF::save_json(const std::string &path)

std::deque<CMDF_Value *> *pvalues = pbit->getListValues();
if (pvalues->size()) {
int pos = 0;
size_t pos = 0;
fout << "," << std::endl;
fout << "\"valuelist\": [" << std::endl;
for (auto it = pvalues->cbegin(); it != pvalues->cend(); ++it) {
Expand Down Expand Up @@ -3107,7 +3107,7 @@ CMDF::save_json(const std::string &path)

std::deque<CMDF_Value *> *pvalues = prvar->getListValues();
if (pvalues->size()) {
int pos = 0;
size_t pos = 0;
fout << "," << std::endl;
fout << "\"valuelist\": [" << std::endl;
for (auto it = pvalues->cbegin(); it != pvalues->cend(); ++it) {
Expand Down Expand Up @@ -3157,7 +3157,7 @@ CMDF::save_json(const std::string &path)
// bits
std::deque<CMDF_Bit *> *pbits = getAlarmList();
if (pbits->size()) {
int pos = 0;
size_t pos = 0;
for (auto it = pbits->cbegin(); it != pbits->cend(); ++it) {
CMDF_Bit *pbit = *it;
fout << "{" << std::endl;
Expand Down Expand Up @@ -3198,7 +3198,7 @@ CMDF::save_json(const std::string &path)
fout << "," << std::endl;
fout << "\"events\": [" << std::endl;

int pos = 0;
size_t pos = 0;

for (auto it = peventlst->cbegin(); it != peventlst->cend(); ++it) {
CMDF_Event *pevent = *it;
Expand All @@ -3213,7 +3213,7 @@ CMDF::save_json(const std::string &path)
std::deque<CMDF_EventData *> *peventdtalst = pevent->getListEventData(); // Get pointer to event list
if (nullptr != peventdtalst) {

int pos = 0;
size_t pos = 0;
fout << "\"data\": [" << std::endl;

for (auto it = peventdtalst->cbegin(); it != peventdtalst->cend(); ++it) {
Expand All @@ -3226,7 +3226,7 @@ CMDF::save_json(const std::string &path)
// bits
std::deque<CMDF_Bit *> *pbits = peventdata->getListBits();
if (pbits->size()) {
int pos = 0;
size_t pos = 0;
fout << "," << std::endl;
fout << "\"bit\": [" << std::endl;
for (auto it = pbits->cbegin(); it != pbits->cend(); ++it) {
Expand All @@ -3246,7 +3246,7 @@ CMDF::save_json(const std::string &path)

std::deque<CMDF_Value *> *pvalues = pbit->getListValues();
if (pvalues->size()) {
int pos = 0;
size_t pos = 0;
fout << "," << std::endl;
fout << "\"valuelist\": [" << std::endl;
for (auto it = pvalues->cbegin(); it != pvalues->cend(); ++it) {
Expand Down Expand Up @@ -3285,7 +3285,7 @@ CMDF::save_json(const std::string &path)

std::deque<CMDF_Value *> *pvalues = peventdata->getListValues();
if (pvalues->size()) {
int pos = 0;
size_t pos = 0;
fout << "," << std::endl;
fout << "\"valuelist\": [" << std::endl;
for (auto it = pvalues->cbegin(); it != pvalues->cend(); ++it) {
Expand Down Expand Up @@ -3673,7 +3673,8 @@ __startSetupMDFParser(void *data, const char *name, const char **attr)
}

// Verify structure <vscp><module>.....</module></vscp>
if (gdepth_xml_parser >= 2 && (gTokenList.at(gTokenList.size() - 2) != "module") || (gTokenList.back() != "vscp")) {
if (((gdepth_xml_parser >= 2) && (gTokenList.at(gTokenList.size() - 2) != "module")) ||
(gTokenList.back() != "vscp")) {
spdlog::error("Parse-XML: startSetupMDFParser: Invalid structure");
return;
}
Expand Down Expand Up @@ -6018,7 +6019,7 @@ __handleMDFParserData(void *data, const XML_Char *content, int length)
(gTokenList.at(1) == "data") &&
(gTokenList.at(2) == "event") &&
(gpEventDataStruct != nullptr)) {
int i = 9;
//int i = 9;
}


Expand Down Expand Up @@ -6847,7 +6848,7 @@ __endSetupMDFParser(void *data, const char *name)
(gTokenList.at(1) == "parm") &&
(gTokenList.at(2) == "action") &&
(gpActionStruct != nullptr)) {
int i = 0;
//int i = 0;
}
// event data
else if ((currentToken == "description") &&
Expand Down
4 changes: 2 additions & 2 deletions src/vscp/common/mdf.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class CMDF_Object {

public:
CMDF_Object(mdf_record_type type = mdf_type_unknown);
~CMDF_Object();
virtual ~CMDF_Object();

/*!
Get the object type
Expand Down Expand Up @@ -236,7 +236,7 @@ class CMDF_Value : public CMDF_Object {

public:
CMDF_Value();
~CMDF_Value();
virtual ~CMDF_Value();

// Friend declarations
friend CMDF;
Expand Down
4 changes: 2 additions & 2 deletions src/vscp/common/vscp-bootdevice-pic1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,11 +879,11 @@ CBootDevice_PIC1::writeFirmwareBlock(uint32_t start, uint32_t end)
int
CBootDevice_PIC1::deviceLoad(std::function<void(int, const char *)> statusCallback)
{
bool bRun = true;
//bool bRun = true;
int rv;

m_checksum = 0;
uint32_t progress = 0;
//uint32_t progress = 0;
uint32_t addr = 0;
std::string strStatus;

Expand Down
36 changes: 20 additions & 16 deletions src/vscp/common/vscp-bootdevice-vscp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/spdlog.h>

#include <iomanip>
#include <iostream>
#include <iomanip>
#include <sstream>

CBootDevice_VSCP::CBootDevice_VSCP(CVscpClient *pclient,
Expand Down Expand Up @@ -260,7 +260,7 @@ CBootDevice_VSCP::deviceInit(cguid &ourguid, uint8_t devicecode, bool bAbortOnFi
m_stdRegs.getGUID(node_guid);

ex.sizeData = 8;
ex.data[0] = (uint8_t)m_nodeid; // Nickname to read register from
ex.data[0] = (uint8_t) m_nodeid; // Nickname to read register from
ex.data[1] = VSCP_BOOTLOADER_VSCP; // VSCP bootloader algorithm
ex.data[2] = node_guid.getAt(0);
ex.data[3] = node_guid.getAt(3);
Expand Down Expand Up @@ -460,7 +460,7 @@ int
CBootDevice_VSCP::writeBlock(const uint8_t *paddr)
{
int rv;
//vscpEventEx ex;
// vscpEventEx ex;
cguid guid;
uint32_t nChunks;

Expand All @@ -481,19 +481,20 @@ CBootDevice_VSCP::writeBlock(const uint8_t *paddr)

spdlog::debug("Loading memory chunk on remote device. chunk={0} {1:X} ", chunk, chunk * m_chunkSize);
if (nullptr != m_statusCallback) {
m_statusCallback((100 * chunk) / nChunks, vscp_str_format("Loading memory chunk on remote device. chunk = %d.", chunk).c_str());
m_statusCallback((100 * chunk) / nChunks,
vscp_str_format("Loading memory chunk on remote device. chunk = %d.", chunk).c_str());
}

if (VSCP_ERROR_SUCCESS != writeChunk(paddr + (m_chunkSize * nChunks), m_chunkSize)) {
spdlog::error("Failed to write chunk to remote device. rv={}", rv);
if (nullptr != m_statusCallback) {
m_statusCallback((100 * chunk) / nChunks, vscp_str_format("Failed to write chunk to remote device rv=%d.", rv).c_str());
m_statusCallback((100 * chunk) / nChunks,
vscp_str_format("Failed to write chunk to remote device rv=%d.", rv).c_str());
}
break;
}

paddr += m_chunkSize;


} // for

Expand All @@ -508,10 +509,10 @@ int
CBootDevice_VSCP::deviceLoad(std::function<void(int, const char *)> statusCallback, bool bAbortOnFirmwareCodeFail)
{
int rv;
//vscpEventEx ex;
// vscpEventEx ex;

uint32_t progress = 0;
//uint32_t addr;
//uint32_t progress = 0;
// uint32_t addr;
std::string strStatus;

m_checksum = 0;
Expand Down Expand Up @@ -630,7 +631,7 @@ CBootDevice_VSCP::deviceLoad(std::function<void(int, const char *)> statusCallba
delete[] pbuf;

} // There is bytes to write
} // for memory types
} // for memory types

return VSCP_ERROR_TIMEOUT;
}
Expand All @@ -642,7 +643,7 @@ CBootDevice_VSCP::deviceLoad(std::function<void(int, const char *)> statusCallba
int
CBootDevice_VSCP::deviceReboot(void)
{
//int rv;
// int rv;

return VSCP_ERROR_SUCCESS;
}
Expand All @@ -658,7 +659,7 @@ CBootDevice_VSCP::checkResponse(vscpEventEx &ex,
uint16_t response_event_nack,
uint32_t timeout)
{
int rv;
int rv = VSCP_ERROR_TIMEOUT;
time_t tstart, tnow;

// Get start time
Expand All @@ -670,6 +671,7 @@ CBootDevice_VSCP::checkResponse(vscpEventEx &ex,
time(&tnow);
if ((unsigned long) (tnow - tstart) > timeout) {
spdlog::debug("VSCP Bootloader: Timeout.");
rv = VSCP_ERROR_TIMEOUT;
break;
}

Expand All @@ -690,7 +692,8 @@ CBootDevice_VSCP::checkResponse(vscpEventEx &ex,
if (nullptr != m_statusCallback) {
m_statusCallback(-1, "VSCP Bootloader:ACK recived");
}
return VSCP_ERROR_SUCCESS;
rv = VSCP_ERROR_SUCCESS;
break;
}

// Is this a read/write reply from the node?
Expand All @@ -701,10 +704,11 @@ CBootDevice_VSCP::checkResponse(vscpEventEx &ex,
if (nullptr != m_statusCallback) {
m_statusCallback(-1, "VSCP Bootloader: NACK recived.");
}
return VSCP_ERROR_NACK;
rv = VSCP_ERROR_NACK;
break;
}
}
} // while

return VSCP_ERROR_TIMEOUT;
return rv;
}
2 changes: 1 addition & 1 deletion src/vscp/common/vscp-bootdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ CBootDevice::loadIntelHexFile(const std::string &path)

// Validate checksum
uint16_t sum = 0;
for (int i = 0; i < linecnt; i++) {
for (size_t i = 0; i < linecnt; i++) {
sum += linebuf[i];
}
if (sum & 0xff) {
Expand Down

0 comments on commit b91d641

Please sign in to comment.