Skip to content

Commit 7d9aade

Browse files
ChristianTackeGSIdennisklein
authored andcommitted
fix most new clang-tidy warnings
Clang-Tidy 15 has added some more warnings. Fix most of them.
1 parent 39bee6b commit 7d9aade

12 files changed

Lines changed: 46 additions & 41 deletions

File tree

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def jobMatrix(String prefix, String type, List specs) {
6767
if (check == "warnings") {
6868
recordIssues(tools: [clangTidy(pattern: logpattern)],
6969
filters: [excludeFile('build/.*/G__.*[.]cxx')],
70-
qualityGates: [[threshold: 3, type: 'NEW', unstable: true]],
70+
qualityGates: [[threshold: 4, type: 'NEW', unstable: true]],
7171
ignoreFailedBuilds: false,
7272
skipBlames: true)
7373
archiveArtifacts(artifacts: logpattern, allowEmptyArchive: true, fingerprint: true)

examples/MQ/pixelDetector/src/devices/FairMQPixelSamplerBin.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014-2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
@@ -96,8 +96,8 @@ bool FairMQPixelSamplerBin::ConditionalRun()
9696
for (int iobj = 0; iobj < fNObjects; iobj++) {
9797
if (strcmp(fInputObjects[iobj]->GetName(), "EventHeader.") == 0) {
9898
PixelPayload::EventHeader* header = new PixelPayload::EventHeader();
99-
header->fRunId = ((FairEventHeader*)fInputObjects[iobj])->GetRunId();
100-
header->fMCEntryNo = ((FairEventHeader*)fInputObjects[iobj])->GetMCEntryNumber();
99+
header->fRunId = static_cast<FairEventHeader*>(fInputObjects[iobj])->GetRunId();
100+
header->fMCEntryNo = static_cast<FairEventHeader*>(fInputObjects[iobj])->GetMCEntryNumber();
101101
header->fPartNo = 0;
102102
auto msgHeader(NewMessage(header, sizeof(PixelPayload::EventHeader), [](void* data, void* /*hint*/) {
103103
delete static_cast<PixelPayload::EventHeader*>(data);
@@ -106,15 +106,15 @@ bool FairMQPixelSamplerBin::ConditionalRun()
106106
// LOG(debug) << "-----------------------------";
107107
// LOG(debug) << "first part has size = " << sizeof(PixelPayload::EventHeader);
108108
} else {
109-
Int_t nofEntries = ((TClonesArray*)fInputObjects[iobj])->GetEntries();
109+
Int_t nofEntries = static_cast<TClonesArray*>(fInputObjects[iobj])->GetEntries();
110110
size_t digisSize = nofEntries * sizeof(PixelPayload::Digi);
111111

112112
auto msgTCA(NewMessage(digisSize));
113113

114114
PixelPayload::Digi* digiPayload = static_cast<PixelPayload::Digi*>(msgTCA->GetData());
115115

116116
for (int idigi = 0; idigi < nofEntries; idigi++) {
117-
PixelDigi* digi = static_cast<PixelDigi*>(((TClonesArray*)fInputObjects[iobj])->At(idigi));
117+
auto digi = static_cast<PixelDigi*>(static_cast<TClonesArray*>(fInputObjects[iobj])->At(idigi));
118118
if (!digi) {
119119
continue;
120120
}

examples/advanced/Tutorial3/MQ/samplerTask/SamplerTask.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class SamplerTask : public FairTask
4747
void SetEventIndex(Long64_t eventIndex) { fEventIndex = eventIndex; }
4848
void SetBranch(const std::string& branch) { fBranch = branch; }
4949

50-
void GetPayload(std::unique_ptr<fair::mq::Message>& msg) { msg = move(fPayload); }
50+
void GetPayload(std::unique_ptr<fair::mq::Message>& msg) { msg = std::move(fPayload); }
5151
void SetTransport(std::shared_ptr<fair::mq::TransportFactory> factory) { fTransportFactory = factory; }
5252

5353
protected:

fairroot/base/sim/FairMCApplication.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,8 +718,8 @@ void FairMCApplication::ConstructOpGeometry()
718718
NK = medium->getNpckov();
719719
if (NK > 0) {
720720
Int_t Mid = 0;
721-
TGeoMedium* Med = 0;
722-
if (gGeoManager && (Med = gGeoManager->GetMedium(medium->GetName()))) {
721+
TGeoMedium* Med = (gGeoManager ? gGeoManager->GetMedium(medium->GetName()) : nullptr);
722+
if (Med) {
723723
Mid = Med->GetId();
724724
} else {
725725
Mid = medium->getMediumIndex();

fairroot/datamatch/FairMCObject.cxx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,12 @@ void FairMCObject::AddLink(FairLink link, int index)
6565

6666
void FairMCObject::AdoptSize(int index)
6767
{
68-
int start = fStage.size();
6968
while (static_cast<int>(fStage.size()) < index + 1) {
7069
FairMCEntry myVec;
7170
myVec.SetPos(fStage.size());
7271
myVec.SetSource(GetStageId());
7372
myVec.SetPersistanceCheck(kFALSE);
7473
fStage.push_back(myVec);
75-
start++;
7674
}
7775
}
7876

fairroot/generators/FairEvtGenGenerator.cxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ FairEvtGenGenerator::FairEvtGenGenerator(const char* fileName)
3636
, fDensityFunction(0)
3737
{
3838
LOG(info) << "FairEvtGenGenerator: Opening input file " << fileName;
39-
if ((fInputFile = fopen(fFileName, "r")) == nullptr)
39+
fInputFile = fopen(fFileName, "r");
40+
if (!fInputFile)
4041
// fInputFile = new ifstream(fFileName);
4142
// if ( ! fInputFile->is_open() )
4243
{
@@ -55,7 +56,8 @@ FairEvtGenGenerator::FairEvtGenGenerator(const char* fileName, Double_t Rsigma,
5556
, fDensityFunction(DensityFunction)
5657
{
5758
LOG(info) << "FairEvtGenGenerator: Opening input file " << fileName;
58-
if ((fInputFile = fopen(fFileName, "r")) == nullptr) {
59+
fInputFile = fopen(fFileName, "r");
60+
if (!fInputFile) {
5961
LOG(fatal) << "Cannot open input file.";
6062
}
6163
}

fairroot/geobase/FairGeoVector.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence (LGPL) version 3, *
@@ -155,7 +155,7 @@ inline FairGeoVector& FairGeoVector::operator=(const FairGeoVector& v)
155155

156156
inline Bool_t FairGeoVector::operator==(const FairGeoVector& v) const
157157
{
158-
return (!(v.getX() != x || v.getY() != y || v.getZ() != z));
158+
return (v.x == x) && (v.y == y) && (v.z == z);
159159
}
160160

161161
inline Bool_t FairGeoVector::operator!=(const FairGeoVector& v) const
@@ -165,22 +165,22 @@ inline Bool_t FairGeoVector::operator!=(const FairGeoVector& v) const
165165
/// check with ilse
166166
inline Bool_t FairGeoVector::operator<(const Double_t a)
167167
{
168-
return !(x >= a || y >= a || z >= a);
168+
return (x < a) && (y < a) && (z < a);
169169
}
170170

171171
inline Bool_t FairGeoVector::operator<=(const Double_t a)
172172
{
173-
return !(x > a || y > a || z > a);
173+
return (x <= a) && (y <= a) && (z <= a);
174174
}
175175

176176
inline Bool_t FairGeoVector::operator>(const Double_t a)
177177
{
178-
return !(x <= a || y <= a || z <= a);
178+
return (x > a) && (y > a) && (z > a);
179179
}
180180

181181
inline Bool_t FairGeoVector::operator>=(const Double_t a)
182182
{
183-
return !(x < a || y < a || z < a);
183+
return (x >= a) & (y >= a) && (z >= a);
184184
}
185185

186186
inline FairGeoVector& FairGeoVector::operator+=(const Double_t a)

fairroot/mcconfigurator/FairYamlVMCConfig.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ FairYamlVMCConfig::FairYamlVMCConfig()
4141
void FairYamlVMCConfig::Setup(const char* mcEngine)
4242
{
4343
fMCEngine = mcEngine;
44-
if (!((strcmp(mcEngine, "TGeant4") == 0) || (strcmp(mcEngine, "TGeant3") == 0))) {
44+
if ((strcmp(mcEngine, "TGeant4") != 0) && (strcmp(mcEngine, "TGeant3") != 0)) {
4545
LOG(fatal) << "FairYamlVMCConfig::Setup() Engine \"" << mcEngine << "\" unknown!";
4646
}
4747

fairroot/parbase/FairContFact.cxx

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -182,22 +182,25 @@ FairParSet* FairContFact::getContainer(const char* name)
182182
// createContainer(FairContainer*), which is implemented in the derived classes
183183
// and calls the corresponding constructor. Then the pointer it added in the
184184
// runtime database.
185-
auto c = static_cast<FairContainer*>((containers->FindObject(name)));
186-
187-
FairParSet* cont = nullptr;
188-
if (c) {
189-
TString cn = c->getConcatName();
190-
FairRuntimeDb* rtdb = FairRuntimeDb::instance();
191-
if (!(cont = rtdb->findContainer(c->getConcatName().Data()))) {
192-
if (strlen(c->getActualContext()) == 0) {
193-
c->setActualContext(c->getDefaultContext());
194-
}
195-
cont = createContainer(c);
196-
if (cont) {
197-
rtdb->addContainer(cont);
198-
}
199-
}
185+
auto c = static_cast<FairContainer*>(containers->FindObject(name));
186+
if (!c) {
187+
return nullptr;
188+
}
189+
190+
FairRuntimeDb* rtdb = FairRuntimeDb::instance();
191+
FairParSet* cont = rtdb->findContainer(c->getConcatName().Data());
192+
if (cont) {
193+
return cont;
200194
}
195+
196+
if (strlen(c->getActualContext()) == 0) {
197+
c->setActualContext(c->getDefaultContext());
198+
}
199+
cont = createContainer(c);
200+
if (cont) {
201+
rtdb->addContainer(cont);
202+
}
203+
201204
return cont;
202205
}
203206

fairroot/parbase/FairParAsciiFileIo.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Bool_t FairParAsciiFileIo::open(const Text_t* fname, const Text_t* status)
5050
// if a file is already open, this file will be closed
5151
// activates detector I/Os
5252
close();
53-
if (!((strcmp(status, "in") == 0) || (strcmp(status, "out") == 0))) {
53+
if ((strcmp(status, "in") != 0) && (strcmp(status, "out") != 0)) {
5454
cout << "Put the right stream option for file " << fname
5555
<< "\n writing state : out\n reading state : in \nopen aborted \n";
5656
return kFALSE;

0 commit comments

Comments
 (0)