Skip to content

Commit a60b5c1

Browse files
committed
fix: -Wsign-compare
Since FairMQ 1.5.0 ``` warning: comparison of integer expressions of different signedness: ‘int’ and ‘fair::mq::Parts::size_type’ {aka ‘long unsigned int’} [-Wsign-compare] ``` see FairRootGroup/FairMQ@a58b487
1 parent 33cfcb9 commit a60b5c1

7 files changed

Lines changed: 26 additions & 24 deletions

File tree

examples/MQ/pixelAlternative/src/devices/FairMQPixAltTaskProcessorBin.h

Lines changed: 2 additions & 2 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-2024 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, *
@@ -72,7 +72,7 @@ class FairMQPixAltTaskProcessorBin : public fair::mq::Device
7272
// creating output multipart message
7373
fair::mq::Parts partsOut;
7474

75-
for (int ievent = 0; ievent < parts.Size() / nPPE; ievent++) {
75+
for (decltype(parts.Size()) ievent = 0; ievent < parts.Size() / nPPE; ievent++) {
7676
// the first part should be the event header
7777
PixelPayload::EventHeader* payloadE =
7878
static_cast<PixelPayload::EventHeader*>(parts.At(nPPE * ievent)->GetData());

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

Lines changed: 3 additions & 3 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-2024 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, *
@@ -57,7 +57,7 @@ void FairMQPixelFileSink::InitTask()
5757
bool FairMQPixelFileSink::StoreData(fair::mq::Parts& parts, int /*index*/)
5858
{
5959
bool creatingTree = false;
60-
auto numParts = parts.Size();
60+
const auto numParts = parts.Size();
6161
std::vector<std::unique_ptr<TObject>> cleanup;
6262
std::vector<TObject*> objectsForBranches;
6363

@@ -68,7 +68,7 @@ bool FairMQPixelFileSink::StoreData(fair::mq::Parts& parts, int /*index*/)
6868

6969
cleanup.reserve(numParts);
7070
objectsForBranches.resize(numParts, nullptr);
71-
for (int ipart = 0; ipart < numParts; ipart++) {
71+
for (decltype(parts.Size()) ipart = 0; ipart < numParts; ipart++) {
7272
auto curobj = RootSerializer().DeserializeTo<TObject>(*parts.At(ipart));
7373
objectsForBranches.at(ipart) = curobj.get();
7474
if (creatingTree) {

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

Lines changed: 9 additions & 6 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-2024 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, *
@@ -100,16 +100,19 @@ void FairMQPixelFileSinkBin::Init()
100100

101101
bool FairMQPixelFileSinkBin::StoreData(fair::mq::Parts& parts, int /*index*/)
102102
{
103-
if (parts.Size() == 0)
103+
const auto numParts = parts.Size();
104+
105+
if (numParts == 0) {
104106
return true; // probably impossible, but still check
107+
}
105108

106109
// expecting even number of parts in the form: header,data,header,data,header,data and so on...
107-
int nPPE = 2; // nof parts per event
110+
constexpr auto nPPE = 2; // nof parts per event
108111

109-
if (parts.Size() % nPPE >= 1)
110-
LOG(info) << "received " << parts.Size() << " parts, will ignore last part!!!";
112+
if (numParts % nPPE >= 1)
113+
LOG(info) << "received " << numParts << " parts, will ignore last part!!!";
111114

112-
for (int ievent = 0; ievent < parts.Size() / nPPE; ievent++) {
115+
for (decltype(parts.Size()) ievent = 0; ievent < numParts / nPPE; ievent++) {
113116
// the first part should be the event header
114117
PixelPayload::EventHeader* payloadE =
115118
static_cast<PixelPayload::EventHeader*>(parts.At(nPPE * ievent)->GetData());

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

Lines changed: 3 additions & 3 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-2024 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, *
@@ -52,9 +52,9 @@ bool FairMQPixelMerger::MergeData(fair::mq::Parts& parts, int /*index*/)
5252
int nofArrays = 0;
5353
// LOG(debug) <<
5454
// "******************************************************************************************************";
55-
for (int ipart = 0; ipart < parts.Size(); ipart++) {
55+
for (auto& part : parts) {
5656
tempObject = nullptr;
57-
RootSerializer().Deserialize(*parts.At(ipart), tempObject);
57+
RootSerializer().Deserialize(*part, tempObject);
5858
if (strcmp(tempObject->GetName(), "EventHeader.") == 0) {
5959
fEventHeader = (PixelEventHeader*)tempObject;
6060
// LOG(debug) << "GOT PART [" << fEventHeader->GetRunId() << "][" << fEventHeader->GetMCEntryNumber() <<

examples/MQ/pixelDetector/src/devices/FairMQPixelTaskProcessor.h

Lines changed: 3 additions & 4 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-2024 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, *
@@ -71,11 +71,10 @@ class FairMQPixelTaskProcessor : public fair::mq::Device
7171
fReceivedMsgs++;
7272

7373
std::vector<TObject*> tempObjects;
74-
for (int ipart = 0; ipart < parts.Size(); ipart++) {
74+
for (auto& part : parts) {
7575
TObject* obj = nullptr;
76-
RootSerializer().Deserialize(*parts.At(ipart), obj);
76+
RootSerializer().Deserialize(*part, obj);
7777
tempObjects.push_back(obj);
78-
// LOG(trace) << "got TObject with name \"" << tempObjects[ipart]->GetName() << "\".";
7978
if (strcmp(tempObjects.back()->GetName(), "EventHeader.") == 0) {
8079
fEventHeader = (FairEventHeader*)(tempObjects.back());
8180
}

examples/MQ/pixelSimSplit/src/devices/FairMQChunkMerger.cxx

Lines changed: 3 additions & 3 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-2024 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, *
@@ -59,9 +59,9 @@ bool FairMQChunkMerger::MergeData(fair::mq::Parts& parts, int /*index*/)
5959
// dataDuplicationFlag = false;
6060

6161
std::vector<TClonesArray*> tcaVector;
62-
for (int ipart = 0; ipart < parts.Size(); ++ipart) {
62+
for (auto& part : parts) {
6363
TObject* tempObject = nullptr;
64-
RootSerializer().Deserialize(*parts.At(ipart), tempObject);
64+
RootSerializer().Deserialize(*part, tempObject);
6565

6666
// LOG(INFO) << "Got object " << tempObject->ClassName() << " named " << tempObject->GetName();
6767
if (strcmp(tempObject->GetName(), "MCEventHeader.") == 0) {

examples/MQ/pixelSimSplit/src/devices/FairMQTransportDevice.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/********************************************************************************
2-
* Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
2+
* Copyright (C) 2014-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
33
* *
44
* This software is distributed under the terms of the *
55
* GNU Lesser General Public Licence version 3 (LGPL) version 3, *
@@ -233,9 +233,9 @@ bool FairMQTransportDevice::TransportData(fair::mq::Parts& mParts, int /*index*/
233233
{
234234
TClonesArray* chunk = nullptr;
235235
FairMCSplitEventHeader* meh = nullptr;
236-
for (int ipart = 0; ipart < mParts.Size(); ipart++) {
236+
for (auto& part : mParts) {
237237
TObject* obj = nullptr;
238-
RootSerializer().Deserialize(*mParts.At(ipart), obj);
238+
RootSerializer().Deserialize(*part, obj);
239239
if (strcmp(obj->GetName(), "MCEvent") == 0)
240240
meh = dynamic_cast<FairMCSplitEventHeader*>(obj);
241241
else if (strcmp(obj->GetName(), "TParticles") == 0)

0 commit comments

Comments
 (0)