From 9ded46639f39f66bff63d1264e3d35420861261a Mon Sep 17 00:00:00 2001 From: Florian Uhlig <f.uhlig@gsi.de> Date: Fri, 30 Jul 2021 13:05:54 +0200 Subject: [PATCH] Fix compiler warnings These compiler warnings are only seen with clang on macosx. Fix format in printf and Form functions. Comment unused parameters. Use correct C++ version when building the external flesnet project. --- external/ipc/CMakeLists.txt | 2 +- .../unpacker/CbmMcbm2018UnpackerAlgoPsd.cxx | 6 ++--- .../unpacker/CbmMcbm2018UnpackerAlgoRich.cxx | 2 +- .../detectors/tof/unpack/CbmTofUnpackAlgo.cxx | 25 ++++++++++--------- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/external/ipc/CMakeLists.txt b/external/ipc/CMakeLists.txt index 645fb9fb15..4ba4e516cc 100644 --- a/external/ipc/CMakeLists.txt +++ b/external/ipc/CMakeLists.txt @@ -65,7 +65,7 @@ ipc/lib/fles_ipc/TimesliceMultiSubscriber.cpp ) -Set_Source_Files_Properties(${SRCS} COMPILE_FLAGS "-std=c++11 -O3 -ggdb -msse4.2 -Wall -Wpedantic -Wextra -Winit-self -Wundef -Wold-style-cast -Woverloaded-virtual -Wwrite-strings -Wnon-virtual-dtor -fno-omit-frame-pointer") +Set_Source_Files_Properties(${SRCS} COMPILE_FLAGS "-std=c++${CMAKE_CXX_STANDARD} -O3 -ggdb -msse4.2 -Wall -Wpedantic -Wextra -Winit-self -Wundef -Wold-style-cast -Woverloaded-virtual -Wwrite-strings -Wnon-virtual-dtor -fno-omit-frame-pointer") Set(LIBRARY_NAME fles_ipc) If(UNIX AND NOT APPLE) diff --git a/fles/mcbm2018/unpacker/CbmMcbm2018UnpackerAlgoPsd.cxx b/fles/mcbm2018/unpacker/CbmMcbm2018UnpackerAlgoPsd.cxx index 7c41ec29bc..c1cc589ad5 100644 --- a/fles/mcbm2018/unpacker/CbmMcbm2018UnpackerAlgoPsd.cxx +++ b/fles/mcbm2018/unpacker/CbmMcbm2018UnpackerAlgoPsd.cxx @@ -290,12 +290,12 @@ Bool_t CbmMcbm2018UnpackerAlgoPsd::ProcessMs(const fles::Timeslice& ts, size_t u if ((fair::Logger::Logging(fair::Severity::debug)) && (uNbMessages > 1)) { printf("%u = %u 64bit messages\n", uSize, uNbMessages); for (uint32_t line_iter = 0; line_iter < uNbMessages - 2; line_iter += 2) { - printf("%010lx", (pInBuff[line_iter] & 0xffffffffff)); - printf("%010lx", (pInBuff[line_iter + 1] & 0xffffffffff)); + printf("%010llx", static_cast<unsigned long long int>(pInBuff[line_iter] & 0xffffffffff)); + printf("%010llx", static_cast<unsigned long long int>(pInBuff[line_iter + 1] & 0xffffffffff)); printf(" %u - %u", line_iter + 1, line_iter + 2); printf("\n"); } - printf("%020lx %u\n", pInBuff[uNbMessages - 1], uNbMessages); + printf("%020llx %u\n", static_cast<unsigned long long int>(pInBuff[uNbMessages - 1]), uNbMessages); } // every 80bit gbt word is decomposed into two 64bit words diff --git a/fles/mcbm2018/unpacker/CbmMcbm2018UnpackerAlgoRich.cxx b/fles/mcbm2018/unpacker/CbmMcbm2018UnpackerAlgoRich.cxx index b69e227e52..4c21a869dd 100644 --- a/fles/mcbm2018/unpacker/CbmMcbm2018UnpackerAlgoRich.cxx +++ b/fles/mcbm2018/unpacker/CbmMcbm2018UnpackerAlgoRich.cxx @@ -653,7 +653,7 @@ Bool_t CbmMcbm2018UnpackerAlgoRich::DebugMs(const fles::Timeslice& ts, size_t uM return kTRUE; } -Int_t CbmMcbm2018UnpackerAlgoRich::Debug(const uint8_t* ptr, const size_t size) { return 0; } +Int_t CbmMcbm2018UnpackerAlgoRich::Debug(const uint8_t* /*ptr*/, const size_t /*size*/) { return 0; } void CbmMcbm2018UnpackerAlgoRich::ErrorMsg(uint16_t errbits, CbmMcbm2018RichErrorType type, uint16_t tdcId) diff --git a/reco/detectors/tof/unpack/CbmTofUnpackAlgo.cxx b/reco/detectors/tof/unpack/CbmTofUnpackAlgo.cxx index 7014a1990f..4fd565ed3f 100644 --- a/reco/detectors/tof/unpack/CbmTofUnpackAlgo.cxx +++ b/reco/detectors/tof/unpack/CbmTofUnpackAlgo.cxx @@ -204,7 +204,7 @@ bool CbmTofUnpackAlgo::unpack(const fles::Timeslice* ts, std::uint16_t icomp, UI LOG(warning) << fName << "::unpack => " << "In timeslice " << fulCurrentTsIdx << " in microslice " << imslice << " component " << icomp << " last message is not an EndOfMs: type " << messageType - << Form(" dump: 0x%16lX", pMess[uIdx].getData()); + << Form(" dump: 0x%16llX", static_cast<unsigned long long int>(pMess[uIdx].getData())); } // else of if( pMess[uIdx].isEndOfMs() ) } // if( uNbMessages - 1 == uIdx ) /* @@ -226,7 +226,7 @@ bool CbmTofUnpackAlgo::unpack(const fles::Timeslice* ts, std::uint16_t icomp, UI LOG(warning) << fName << "::unpack => " << "In timeslice " << fulCurrentTsIdx << " in microslice " << imslice << " component " << icomp << " first message is not an epoch: type " << messageType - << Form(" dump: 0x%16lX", pMess[uIdx].getData()); + << Form(" dump: 0x%16llX", static_cast<unsigned long long int>(pMess[uIdx].getData())); LOG(warning) << fName << "::unpack => " << "Ignoring this microslice."; return false; @@ -300,12 +300,13 @@ void CbmTofUnpackAlgo::ProcessEpoch(const critof001::Message& mess, uint32_t uMe if (ulEpochNr != ulMsStartInEpoch) { // size_t required to silence a warning on macos (there a uint64_t is a llu) - LOG(error) << fName << "::ProcessEpoch => Error first global epoch, " - << Form( - "from MS index 0x%06lx, current 0x%06llx, diff %lld, raw 0x%016lx, NoErr %d, current 0x%06lx %f", - ulMsStartInEpoch, ulEpochNr, ulEpochNr - ulMsStartInEpoch, mess.getData(), fuProcEpochUntilError, - static_cast<size_t>(fulCurrentMsIdx / critof001::kuEpochInNs), - fulCurrentMsIdx / critof001::kuEpochInNs); + LOG(error) + << fName << "::ProcessEpoch => Error first global epoch, " + << Form("from MS index 0x%06llx, current 0x%06llx, diff %lld, raw 0x%016llx, NoErr %d, current 0x%06lx %f", + static_cast<unsigned long long int>(ulMsStartInEpoch), ulEpochNr, ulEpochNr - ulMsStartInEpoch, + static_cast<unsigned long long int>(mess.getData()), fuProcEpochUntilError, + static_cast<size_t>(fulCurrentMsIdx / critof001::kuEpochInNs), + fulCurrentMsIdx / critof001::kuEpochInNs); LOG(error) << fName << "::ProcessEpoch => Ignoring data until next valid epoch"; fbLastEpochGood = false; @@ -341,10 +342,10 @@ void CbmTofUnpackAlgo::ProcessEpoch(const critof001::Message& mess, uint32_t uMe if (10e9 < critof001::kuEpochInNs * fulEpochIndexInTs) // Cast required to silence a warning on macos (there a uint64_t is a llu) LOG(debug) << fName << "::ProcessEpoch => " - << Form("Raw Epoch: 0x%06llx, Epoch offset 0x%06lx, Epoch in Ts: 0x%07lx, time %f ns (%f * %lu)", - ulEpochNr, fulTsStartInEpoch, static_cast<size_t>(fulEpochIndexInTs), - critof001::kuEpochInNs * fulEpochIndexInTs, critof001::kuEpochInNs, - static_cast<size_t>(fulEpochIndexInTs)); + << Form("Raw Epoch: 0x%06llx, Epoch offset 0x%06llx, Epoch in Ts: 0x%07lx, time %f ns (%f * %lu)", + ulEpochNr, static_cast<long long unsigned int>(fulTsStartInEpoch), + static_cast<size_t>(fulEpochIndexInTs), critof001::kuEpochInNs * fulEpochIndexInTs, + critof001::kuEpochInNs, static_cast<size_t>(fulEpochIndexInTs)); } void CbmTofUnpackAlgo::ProcessHit(const critof001::Message& mess) -- GitLab