From 0c5633bed2997c646e1d3bedce7ac313d5488273 Mon Sep 17 00:00:00 2001 From: Richard Chapman Date: Wed, 11 Sep 2024 14:53:18 +0100 Subject: [PATCH] HPCC-32809 Fix warnings in tools subdirectory Signed-off-by: Richard Chapman --- tools/CMakeLists.txt | 4 +++- tools/copyexp/copyexp.cpp | 1 - tools/testsocket/testsocket.cpp | 4 +--- tools/vkey/vkey.cpp | 20 +++++++++--------- tools/wutool/wutool.cpp | 36 +++++++++++++++------------------ 5 files changed, 30 insertions(+), 35 deletions(-) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 930d1d770ec..c59adc318ea 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -13,6 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. ################################################################################ +project (tools) HPCC_ADD_SUBDIRECTORY (esdlcomp) HPCC_ADD_SUBDIRECTORY (hidl) HPCC_ADD_SUBDIRECTORY (esdlcmd-xml) @@ -23,12 +24,13 @@ IF (USE_OPENLDAP) HPCC_ADD_SUBDIRECTORY (initldap "PLATFORM") ENDIF(USE_OPENLDAP) HPCC_ADD_SUBDIRECTORY (combine "PLATFORM") +HPCC_ADD_SUBDIRECTORY (swapnode "PLATFORM") +SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${STRICT_CXX_FLAGS}") HPCC_ADD_SUBDIRECTORY (dumpkey "PLATFORM") HPCC_ADD_SUBDIRECTORY (keydiff "PLATFORM") HPCC_ADD_SUBDIRECTORY (pstart "PLATFORM") HPCC_ADD_SUBDIRECTORY (pskill "PLATFORM") HPCC_ADD_SUBDIRECTORY (testsocket) -HPCC_ADD_SUBDIRECTORY (swapnode "PLATFORM") HPCC_ADD_SUBDIRECTORY (vkey "PLATFORM") HPCC_ADD_SUBDIRECTORY (wuget "CLIENTTOOLS") HPCC_ADD_SUBDIRECTORY (wutool "PLATFORM") diff --git a/tools/copyexp/copyexp.cpp b/tools/copyexp/copyexp.cpp index 9b67a15cd3a..f052a8309df 100644 --- a/tools/copyexp/copyexp.cpp +++ b/tools/copyexp/copyexp.cpp @@ -399,7 +399,6 @@ int main(int argc, char * const * argv) try { bool test=false; - unsigned arg = 1; StringBuffer fname1; StringBuffer fname2; bool lzw = false; diff --git a/tools/testsocket/testsocket.cpp b/tools/testsocket/testsocket.cpp index ebbaff42aa4..4123b88efcc 100644 --- a/tools/testsocket/testsocket.cpp +++ b/tools/testsocket/testsocket.cpp @@ -242,14 +242,12 @@ int readResults(ISocket * socket, bool readBlocked, bool useHTTP, StringBuffer & break; } - bool isSpecial = false; bool pluginRequest = false; bool dataBlockRequest = false; bool remoteReadRequest = false; if (len & 0x80000000) { unsigned char flag; - isSpecial = true; socket->read(&flag, sizeof(flag)); switch (flag) { @@ -395,7 +393,7 @@ int readResults(ISocket * socket, bool readBlocked, bool useHTTP, StringBuffer & mb.read(dataLen); if (!dataLen) break; - const void *rowData = mb.readDirect(dataLen); + [[maybe_unused]] const void *rowData = mb.readDirect(dataLen); // JCSMORE - output binary row data? // cursor diff --git a/tools/vkey/vkey.cpp b/tools/vkey/vkey.cpp index 9379f1e12ef..ce63a31a6ce 100644 --- a/tools/vkey/vkey.cpp +++ b/tools/vkey/vkey.cpp @@ -159,16 +159,16 @@ unsigned long mcrc32(const char *buf, unsigned len, unsigned long crc) switch (len) { - case 11: c = *buf++; crc = UPDC32(c,crc); - case 10: c = *buf++; crc = UPDC32(c,crc); - case 9: c = *buf++; crc = UPDC32(c,crc); - case 8: c = *buf++; crc = UPDC32(c,crc); - case 7: c = *buf++; crc = UPDC32(c,crc); - case 6: c = *buf++; crc = UPDC32(c,crc); - case 5: c = *buf++; crc = UPDC32(c,crc); - case 4: c = *buf++; crc = UPDC32(c,crc); - case 3: c = *buf++; crc = UPDC32(c,crc); - case 2: c = *buf++; crc = UPDC32(c,crc); + case 11: c = *buf++; crc = UPDC32(c,crc); [[fallthrough]]; + case 10: c = *buf++; crc = UPDC32(c,crc); [[fallthrough]]; + case 9: c = *buf++; crc = UPDC32(c,crc); [[fallthrough]]; + case 8: c = *buf++; crc = UPDC32(c,crc); [[fallthrough]]; + case 7: c = *buf++; crc = UPDC32(c,crc); [[fallthrough]]; + case 6: c = *buf++; crc = UPDC32(c,crc); [[fallthrough]]; + case 5: c = *buf++; crc = UPDC32(c,crc); [[fallthrough]]; + case 4: c = *buf++; crc = UPDC32(c,crc); [[fallthrough]]; + case 3: c = *buf++; crc = UPDC32(c,crc); [[fallthrough]]; + case 2: c = *buf++; crc = UPDC32(c,crc); [[fallthrough]]; case 1: c = *buf++; crc = UPDC32(c,crc); } diff --git a/tools/wutool/wutool.cpp b/tools/wutool/wutool.cpp index 45c46a4bde1..e973810d9da 100644 --- a/tools/wutool/wutool.cpp +++ b/tools/wutool/wutool.cpp @@ -140,12 +140,10 @@ class ScopeDumper : public IWuScopeVisitor SCMStringBuffer curFormattedValue; StatisticCreatorType curCreatorType = cur.getCreatorType(); - StatisticScopeType curScopeType = cur.getScopeType(); StatisticMeasure curMeasure = cur.getMeasure(); unsigned __int64 count = cur.getCount(); unsigned __int64 max = cur.getMax(); unsigned __int64 ts = cur.getTimestamp(); - const char * curScope = cur.queryScope(); cur.getCreator(curCreator); cur.getDescription(curDescription, false); cur.getFormattedValue(curFormattedValue); @@ -371,7 +369,6 @@ int main(int argc, const char *argv[]) int ret = 0; InitModuleObjects(); Owned dummyconfig = loadConfiguration(defaultYaml, argv, "wutool", "WUTOOL", "wutool.xml", nullptr, nullptr, false); - unsigned count=0; globals.setown(createProperties("wutool.ini", true)); const char *action = NULL; StringArray wuids; @@ -842,11 +839,11 @@ class WuTool : public CppUnit::TestFixture Owned factory = getWorkUnitFactory(); unsigned before = factory->numWorkUnits(); unsigned start = msTick(); - for (int i = 0; i < testSize; i++) + for (unsigned i = 0; i < testSize; i++) { - VStringBuffer userId("WuTestUser%02d", i % 50); - VStringBuffer clusterName("WuTestCluster%d", i % 5); - VStringBuffer jobName("WuTest job %d", i % 3); + VStringBuffer userId("WuTestUser%02u", i % 50); + VStringBuffer clusterName("WuTestCluster%u", i % 5); + VStringBuffer jobName("WuTest job %u", i % 3); Ownedwu = factory->createWorkUnit("WuTest", NULL, NULL, NULL); if (i % 6) wu->setState(WUStateCompleted); @@ -864,15 +861,15 @@ class WuTool : public CppUnit::TestFixture // We should really be doing a noteFileRead here but the API is such a pain that we'll do it this way IPropertyTree *p = queryExtendedWU(wu)->queryPTree(); VStringBuffer fileinfo(" " - " " + " " " " - " " + " " " " " ", i % 10, i % 10); p->setPropTree("FilesRead", createPTreeFromXMLString(fileinfo)); wu->noteFileRead(NULL); // Make sure we notice that it was modified - VStringBuffer myFileW("myfilewritten%02d", i % 10); + VStringBuffer myFileW("myfilewritten%02u", i % 10); wu->addFile(myFileW, NULL, i % 3, WUFileStandard, NULL); } unsigned after = factory->numWorkUnits(); @@ -1424,7 +1421,7 @@ class WuTool : public CppUnit::TestFixture Owned factory = getWorkUnitFactory(); unsigned before = factory->numWorkUnits(); unsigned start = msTick(); - for (int i = 0; i < testSize; i++) + for (unsigned i = 0; i < testSize; i++) { factory->deleteWorkUnit(wuids.item(i)); } @@ -1438,7 +1435,7 @@ class WuTool : public CppUnit::TestFixture { Owned factory = getWorkUnitFactory(); unsigned start = msTick(); - int i; + unsigned i; for (i = 0; i < testSize; i++) { Owned wu = factory->updateWorkUnit(wuids.item(i)); @@ -1494,7 +1491,7 @@ class WuTool : public CppUnit::TestFixture } ASSERT(wu->getExceptionCount() == 10); Owned exceptions = &wu->getExceptions(); - int exNo = 0; + unsigned exNo = 0; ForEach(*exceptions) { IConstWUException &ex = exceptions->query(); @@ -1588,7 +1585,7 @@ class WuTool : public CppUnit::TestFixture { Owned factory = getWorkUnitFactory(); unsigned start = msTick(); - int i; + unsigned i; for (i = 0; i < testSize; i++) { Owned wu = factory->updateWorkUnit(wuids.item(i)); @@ -1755,7 +1752,7 @@ class WuTool : public CppUnit::TestFixture start = msTick(); StringArray users; factory->getUniqueValues(WUSFuser, "WUTest", users); - int expected = testSize < 50 ? testSize : 50; + unsigned expected = testSize < 50 ? testSize : 50; ASSERT(users.length() == expected); ForEachItemIn(idx, users) { @@ -1935,7 +1932,6 @@ class WuTool : public CppUnit::TestFixture void testList2() { Owned factory = getWorkUnitFactory(); - bool isDali = streq(factory->queryStoreType(), "Dali"); unsigned before = factory->numWorkUnits(); unsigned start = msTick(); unsigned numIterated = 0; @@ -1968,7 +1964,6 @@ class WuTool : public CppUnit::TestFixture void testListByAppValue() { Owned factory = getWorkUnitFactory(); - bool isDali = streq(factory->queryStoreType(), "Dali"); unsigned start = msTick(); unsigned numIterated = 0; // Test filter by appValue @@ -2095,6 +2090,8 @@ class WuTool : public CppUnit::TestFixture } void testWorkUnitServices() { + #if 0 + // These tests are not valid at present, since the C++ structure does not accurately describe the variable layout fields class DummyContext: implements ICodeContext { virtual const char *loadResource(unsigned id) { throwUnexpected(); } @@ -2212,8 +2209,6 @@ class WuTool : public CppUnit::TestFixture } ctx; - #if 0 - // These tests are not valid at present, since the C++ structure does not accurately describe the variable layout fields size32_t lenResult; void * result; wsWorkunitList(&ctx, lenResult, result, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, true, false, NULL); @@ -2304,7 +2299,8 @@ class WuDetails : public CppUnit::TestFixture } virtual void noteException(IConstWUException & exception) override { - noteException(exception); + SCMStringBuffer s; + DBGLOG(" Exception: %s", exception.getExceptionMessage(s).str()); } };