From b91d641e3fb1524bbbc5fa378076996ba3e56c77 Mon Sep 17 00:00:00 2001 From: Ake Hedman Date: Thu, 17 Oct 2024 16:29:42 +0200 Subject: [PATCH] Fixed some build warnings --- src/vscp/common/mdf.cpp | 43 ++++++++++++------------ src/vscp/common/mdf.h | 4 +-- src/vscp/common/vscp-bootdevice-pic1.cpp | 4 +-- src/vscp/common/vscp-bootdevice-vscp.cpp | 36 +++++++++++--------- src/vscp/common/vscp-bootdevice.cpp | 2 +- 5 files changed, 47 insertions(+), 42 deletions(-) diff --git a/src/vscp/common/mdf.cpp b/src/vscp/common/mdf.cpp index 1cc0a60a8..69de68951 100644 --- a/src/vscp/common/mdf.cpp +++ b/src/vscp/common/mdf.cpp @@ -2089,7 +2089,7 @@ CMDF::save_xml(const std::string &path) std::deque *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 << "getName() << "\" "; @@ -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) { @@ -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) { @@ -2872,10 +2872,10 @@ CMDF::save_json(const std::string &path) // get pages std::set pages; std::deque *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 regset; @@ -2910,7 +2910,7 @@ CMDF::save_json(const std::string &path) // bits std::deque *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) { @@ -2930,7 +2930,7 @@ CMDF::save_json(const std::string &path) std::deque *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) { @@ -2969,7 +2969,7 @@ CMDF::save_json(const std::string &path) std::deque *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) { @@ -3029,7 +3029,7 @@ CMDF::save_json(const std::string &path) std::deque *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; @@ -3048,7 +3048,7 @@ CMDF::save_json(const std::string &path) // bits std::deque *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) { @@ -3068,7 +3068,7 @@ CMDF::save_json(const std::string &path) std::deque *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) { @@ -3107,7 +3107,7 @@ CMDF::save_json(const std::string &path) std::deque *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) { @@ -3157,7 +3157,7 @@ CMDF::save_json(const std::string &path) // bits std::deque *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; @@ -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; @@ -3213,7 +3213,7 @@ CMDF::save_json(const std::string &path) std::deque *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) { @@ -3226,7 +3226,7 @@ CMDF::save_json(const std::string &path) // bits std::deque *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) { @@ -3246,7 +3246,7 @@ CMDF::save_json(const std::string &path) std::deque *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) { @@ -3285,7 +3285,7 @@ CMDF::save_json(const std::string &path) std::deque *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) { @@ -3673,7 +3673,8 @@ __startSetupMDFParser(void *data, const char *name, const char **attr) } // Verify structure ..... - 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; } @@ -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; } @@ -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") && diff --git a/src/vscp/common/mdf.h b/src/vscp/common/mdf.h index 634be2f65..428ccfc1e 100644 --- a/src/vscp/common/mdf.h +++ b/src/vscp/common/mdf.h @@ -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 @@ -236,7 +236,7 @@ class CMDF_Value : public CMDF_Object { public: CMDF_Value(); - ~CMDF_Value(); + virtual ~CMDF_Value(); // Friend declarations friend CMDF; diff --git a/src/vscp/common/vscp-bootdevice-pic1.cpp b/src/vscp/common/vscp-bootdevice-pic1.cpp index f8419c980..1d45e2c35 100644 --- a/src/vscp/common/vscp-bootdevice-pic1.cpp +++ b/src/vscp/common/vscp-bootdevice-pic1.cpp @@ -879,11 +879,11 @@ CBootDevice_PIC1::writeFirmwareBlock(uint32_t start, uint32_t end) int CBootDevice_PIC1::deviceLoad(std::function 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; diff --git a/src/vscp/common/vscp-bootdevice-vscp.cpp b/src/vscp/common/vscp-bootdevice-vscp.cpp index 3f4b4cb37..9995a095d 100644 --- a/src/vscp/common/vscp-bootdevice-vscp.cpp +++ b/src/vscp/common/vscp-bootdevice-vscp.cpp @@ -43,8 +43,8 @@ #include #include +#include #include -#include #include CBootDevice_VSCP::CBootDevice_VSCP(CVscpClient *pclient, @@ -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); @@ -460,7 +460,7 @@ int CBootDevice_VSCP::writeBlock(const uint8_t *paddr) { int rv; - //vscpEventEx ex; + // vscpEventEx ex; cguid guid; uint32_t nChunks; @@ -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 @@ -508,10 +509,10 @@ int CBootDevice_VSCP::deviceLoad(std::function 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; @@ -630,7 +631,7 @@ CBootDevice_VSCP::deviceLoad(std::function statusCallba delete[] pbuf; } // There is bytes to write - } // for memory types + } // for memory types return VSCP_ERROR_TIMEOUT; } @@ -642,7 +643,7 @@ CBootDevice_VSCP::deviceLoad(std::function statusCallba int CBootDevice_VSCP::deviceReboot(void) { - //int rv; + // int rv; return VSCP_ERROR_SUCCESS; } @@ -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 @@ -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; } @@ -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? @@ -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; } diff --git a/src/vscp/common/vscp-bootdevice.cpp b/src/vscp/common/vscp-bootdevice.cpp index b0d022934..a6af0b58a 100644 --- a/src/vscp/common/vscp-bootdevice.cpp +++ b/src/vscp/common/vscp-bootdevice.cpp @@ -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) {