From ad2417548bf06ad71d6105bae43bca717321ee76 Mon Sep 17 00:00:00 2001 From: sgorbuno <se.gorbunov@gsi.de> Date: Sat, 14 Nov 2020 00:01:11 +0000 Subject: [PATCH] BugFix in pluto/PDataBase, fix of compiler warnings --- .../common/at_kfpf_interface/ATKFParticleFinder.cxx | 4 ++-- core/detectors/much/CbmMuchGeoScheme.cxx | 4 ++-- core/detectors/much/CbmMuchSegmentManual.h | 2 +- core/detectors/much/CbmMuchSegmentSector.h | 2 +- core/detectors/tof/CbmTofGeoHandler.cxx | 4 ++-- fles/mcbm2018/monitor/CbmMcbm2018MonitorMuch.cxx | 2 +- fles/mcbm2018/monitor/CbmMcbm2018MonitorMuchLite.cxx | 2 +- fles/mcbm2018/monitor/CbmMcbm2018MonitorSts.cxx | 2 +- fles/mcbm2018/parameter/CbmMcbm2018PsdPar.cxx | 2 +- fles/mcbm2018/parameter/CbmMcbm2018TofPar.cxx | 12 ++++-------- sim/transport/generators/pluto/PDataBase.cxx | 4 ++-- sim/transport/generators/pluto/PDataBase.h | 2 +- 12 files changed, 19 insertions(+), 23 deletions(-) diff --git a/analysis/common/at_kfpf_interface/ATKFParticleFinder.cxx b/analysis/common/at_kfpf_interface/ATKFParticleFinder.cxx index 1895d7cba3..9d52c9c877 100644 --- a/analysis/common/at_kfpf_interface/ATKFParticleFinder.cxx +++ b/analysis/common/at_kfpf_interface/ATKFParticleFinder.cxx @@ -103,7 +103,7 @@ KFParticleTopoReconstructor* ATKFParticleFinder::CreateTopoReconstructor() { int n_good_tracks = 0; - for (int i_track = 0; i_track < kf_tracks_->GetNumberOfChannels(); + for (unsigned int i_track = 0; i_track < kf_tracks_->GetNumberOfChannels(); i_track++) { const AnalysisTree::Track& rec_track = kf_tracks_->GetChannel(i_track); if (rec_track.GetField<bool>(passcuts_field_id_) == 0) continue; @@ -117,7 +117,7 @@ KFParticleTopoReconstructor* ATKFParticleFinder::CreateTopoReconstructor() { int j_track = 0; - for (int i_track = 0; i_track < kf_tracks_->GetNumberOfChannels(); + for (unsigned int i_track = 0; i_track < kf_tracks_->GetNumberOfChannels(); i_track++) { const AnalysisTree::Track& rec_track = kf_tracks_->GetChannel(i_track); diff --git a/core/detectors/much/CbmMuchGeoScheme.cxx b/core/detectors/much/CbmMuchGeoScheme.cxx index ef40084839..1ae081aba6 100644 --- a/core/detectors/much/CbmMuchGeoScheme.cxx +++ b/core/detectors/much/CbmMuchGeoScheme.cxx @@ -379,7 +379,7 @@ CbmMuchGeoScheme::GetLayerSides(Int_t iStation) const { try { return fSides.at(iStation); - } catch (std::out_of_range exc) { + } catch (const std::out_of_range& exc) { Fatal("GetLayerSides", "No input array of stations."); } return vector<CbmMuchLayerSide*>(); @@ -895,7 +895,7 @@ vector<CbmMuchModule*> CbmMuchGeoScheme::GetModules(Int_t iStation) const { try { return fModules.at(iStation); - } catch (std::out_of_range exc) { + } catch (const std::out_of_range& exc) { Fatal("GetModules", "No input array of stations."); } return vector<CbmMuchModule*>(); diff --git a/core/detectors/much/CbmMuchSegmentManual.h b/core/detectors/much/CbmMuchSegmentManual.h index e5208472fe..7447b3c63c 100644 --- a/core/detectors/much/CbmMuchSegmentManual.h +++ b/core/detectors/much/CbmMuchSegmentManual.h @@ -256,7 +256,7 @@ private: std::stringstream ss(str); if ((ss >> number).fail() || !(ss >> std::ws).eof()) throw std::bad_cast(); - } catch (std::bad_cast exc) { Fatal("", "Invalid cast.\n"); } + } catch (const std::bad_cast& exc) { Fatal("", "Invalid cast.\n"); } } // -------------------------------------------------------------------------------- diff --git a/core/detectors/much/CbmMuchSegmentSector.h b/core/detectors/much/CbmMuchSegmentSector.h index 8a98c316cf..dffaac7fd3 100644 --- a/core/detectors/much/CbmMuchSegmentSector.h +++ b/core/detectors/much/CbmMuchSegmentSector.h @@ -152,7 +152,7 @@ private: std::stringstream ss(str); if ((ss >> number).fail() || !(ss >> std::ws).eof()) throw std::bad_cast(); - } catch (std::bad_cast exc) { Fatal("", "Invalid cast.\n"); } + } catch (const std::bad_cast& exc) { Fatal("", "Invalid cast.\n"); } } // -------------------------------------------------------------------------------- diff --git a/core/detectors/tof/CbmTofGeoHandler.cxx b/core/detectors/tof/CbmTofGeoHandler.cxx index e6c9f1e9c5..51b61a2441 100644 --- a/core/detectors/tof/CbmTofGeoHandler.cxx +++ b/core/detectors/tof/CbmTofGeoHandler.cxx @@ -405,10 +405,10 @@ Int_t CbmTofGeoHandler::VolId(const Text_t* name) const { // // Return the unique numeric identifier for volume name // - char sname[20]; Int_t len = strlen(name) - 1; if (name[len] != ' ') { return VolIdGeo(name); } - strncpy(sname, name, len); + char sname[len + 1]; + memcpy(sname, name, len); sname[len] = 0; return VolIdGeo(sname); } diff --git a/fles/mcbm2018/monitor/CbmMcbm2018MonitorMuch.cxx b/fles/mcbm2018/monitor/CbmMcbm2018MonitorMuch.cxx index b4dd067f8c..f13405c175 100644 --- a/fles/mcbm2018/monitor/CbmMcbm2018MonitorMuch.cxx +++ b/fles/mcbm2018/monitor/CbmMcbm2018MonitorMuch.cxx @@ -346,7 +346,7 @@ void CbmMcbm2018MonitorMuch::AddMsComponentToList(size_t component, LOG(error) << "CbmMcbm2018MonitorMuch::AddMsComponentToList => " << "Ignored the addition of component " << component << " as it is above the hadcoded limit of " - << static_cast<const Int_t>(kiMaxNbFlibLinks) << " !!!!!!!!! " + << static_cast<Int_t>(kiMaxNbFlibLinks) << " !!!!!!!!! " << "\n" << " To change this behavior check kiMaxNbFlibLinks in " "CbmMcbm2018MonitorMuch.cxx"; diff --git a/fles/mcbm2018/monitor/CbmMcbm2018MonitorMuchLite.cxx b/fles/mcbm2018/monitor/CbmMcbm2018MonitorMuchLite.cxx index 59dfabd1df..694977d370 100644 --- a/fles/mcbm2018/monitor/CbmMcbm2018MonitorMuchLite.cxx +++ b/fles/mcbm2018/monitor/CbmMcbm2018MonitorMuchLite.cxx @@ -333,7 +333,7 @@ void CbmMcbm2018MonitorMuchLite::AddMsComponentToList( LOG(error) << "CbmMcbm2018MonitorMuchLite::AddMsComponentToList => " << "Ignored the addition of component " << component << " as it is above the hadcoded limit of " - << static_cast<const Int_t>(kiMaxNbFlibLinks) << " !!!!!!!!! " + << static_cast<Int_t>(kiMaxNbFlibLinks) << " !!!!!!!!! " << "\n" << " To change this behavior check kiMaxNbFlibLinks in " "CbmMcbm2018MonitorMuchLite.cxx"; diff --git a/fles/mcbm2018/monitor/CbmMcbm2018MonitorSts.cxx b/fles/mcbm2018/monitor/CbmMcbm2018MonitorSts.cxx index 1737feeb28..5256de3817 100644 --- a/fles/mcbm2018/monitor/CbmMcbm2018MonitorSts.cxx +++ b/fles/mcbm2018/monitor/CbmMcbm2018MonitorSts.cxx @@ -445,7 +445,7 @@ void CbmMcbm2018MonitorSts::AddMsComponentToList(size_t component, LOG(error) << "CbmMcbm2018MonitorSts::AddMsComponentToList => " << "Ignored the addition of component " << component << " as it is above the hadcoded limit of " - << static_cast<const Int_t>(kiMaxNbFlibLinks) << " !!!!!!!!! " + << static_cast<Int_t>(kiMaxNbFlibLinks) << " !!!!!!!!! " << "\n" << " To change this behavior check kiMaxNbFlibLinks in " "CbmMcbm2018MonitorSts.cxx"; diff --git a/fles/mcbm2018/parameter/CbmMcbm2018PsdPar.cxx b/fles/mcbm2018/parameter/CbmMcbm2018PsdPar.cxx index 2bbd9cd6e7..f629d23aad 100644 --- a/fles/mcbm2018/parameter/CbmMcbm2018PsdPar.cxx +++ b/fles/mcbm2018/parameter/CbmMcbm2018PsdPar.cxx @@ -102,7 +102,7 @@ Int_t CbmMcbm2018PsdPar::FeeChanToGbtChan(UInt_t uChannelInFee) { else { LOG(fatal) << "CbmMcbm2018PsdPar::FeeChanToGbtChan => Index out of bound, " << uChannelInFee << " vs " - << static_cast<const uint32_t>(kuNbChannelsPerFee) + << static_cast<uint32_t>(kuNbChannelsPerFee) << ", returning crazy value!"; return -1; } // else of if( uChannelInFee < kuNbChannelsPerFee ) diff --git a/fles/mcbm2018/parameter/CbmMcbm2018TofPar.cxx b/fles/mcbm2018/parameter/CbmMcbm2018TofPar.cxx index 6732b6805c..e93e7e13c8 100644 --- a/fles/mcbm2018/parameter/CbmMcbm2018TofPar.cxx +++ b/fles/mcbm2018/parameter/CbmMcbm2018TofPar.cxx @@ -150,8 +150,7 @@ Int_t CbmMcbm2018TofPar::Get4ChanToPadiChan(UInt_t uChannelInFee) { else { LOG(fatal) << "CbmMcbm2018TofPar::Get4ChanToPadiChan => Index out of bound, " - << uChannelInFee << " vs " - << static_cast<const uint32_t>(kuNbChannelsPerFee) + << uChannelInFee << " vs " << static_cast<uint32_t>(kuNbChannelsPerFee) << ", returning crazy value!"; return -1; } // else of if( uChannelInFee < kuNbChannelsPerFee ) @@ -162,8 +161,7 @@ Int_t CbmMcbm2018TofPar::PadiChanToGet4Chan(UInt_t uChannelInFee) { else { LOG(fatal) << "CbmMcbm2018TofPar::PadiChanToGet4Chan => Index out of bound, " - << uChannelInFee << " vs " - << static_cast<const uint32_t>(kuNbChannelsPerFee) + << uChannelInFee << " vs " << static_cast<uint32_t>(kuNbChannelsPerFee) << ", returning crazy value!"; return -1; } // else of if( uChannelInFee < kuNbChannelsPerFee ) @@ -177,8 +175,7 @@ Int_t CbmMcbm2018TofPar::ElinkIdxToGet4Idx(UInt_t uElink) { + kuNbGet4PerGbtx * (uElink / kuNbGet4PerGbtx); else { LOG(fatal) << "CbmMcbm2018TofPar::ElinkIdxToGet4Idx => Index out of bound, " - << uElink << " vs " - << static_cast<const uint32_t>(kuNbGet4PerGdpb) + << uElink << " vs " << static_cast<uint32_t>(kuNbGet4PerGdpb) << ", returning crazy value!"; return -1; } // else of if( uElink < kuNbGet4PerGbtx ) @@ -191,8 +188,7 @@ Int_t CbmMcbm2018TofPar::Get4IdxToElinkIdx(UInt_t uGet4) { + kuNbGet4PerGbtx * (uGet4 / kuNbGet4PerGbtx); else { LOG(fatal) << "CbmMcbm2018TofPar::Get4IdxToElinkIdx => Index out of bound, " - << uGet4 << " vs " - << static_cast<const uint32_t>(kuNbGet4PerGdpb) + << uGet4 << " vs " << static_cast<uint32_t>(kuNbGet4PerGdpb) << ", returning crazy value!"; return -1; } // else of if( uElink < kuNbGet4PerGbtx ) diff --git a/sim/transport/generators/pluto/PDataBase.cxx b/sim/transport/generators/pluto/PDataBase.cxx index ce42996f9c..24f8b0af79 100644 --- a/sim/transport/generators/pluto/PDataBase.cxx +++ b/sim/transport/generators/pluto/PDataBase.cxx @@ -225,7 +225,7 @@ Int_t PDataBase ::ConvertParamKey(const char*& newparamname, Int_t key) { return -1; }; -char* PDataBase ::GetDescription(const char* paramname) { +TString PDataBase ::GetDescription(const char* paramname) { //Interpretation of pattern TString spattern(paramname); TObjArray* array = spattern.Tokenize(TString(":")); @@ -252,7 +252,7 @@ char* PDataBase ::GetDescription(const char* paramname) { done = 1; } } - return (char*) bla.Data(); + return bla; } Bool_t PDataBase ::GetParamDouble(Int_t key, diff --git a/sim/transport/generators/pluto/PDataBase.h b/sim/transport/generators/pluto/PDataBase.h index bd352f7dd9..cf127ab151 100644 --- a/sim/transport/generators/pluto/PDataBase.h +++ b/sim/transport/generators/pluto/PDataBase.h @@ -89,7 +89,7 @@ public: Int_t length = -1); //get "paramname" from string database Int_t GetParamTObj(const char* paramname); - char* GetDescription(const char* paramname); + TString GetDescription(const char* paramname); void GetFastParamInt(const char* paramname, Int_t* pkey) { if ((*pkey) < 0) *pkey = GetParamInt(paramname); -- GitLab