Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,9 @@ class HuffmanModel : public _BASE
}
node->getLeftChild()->setBinaryCode(codelen + 1, c);
int branchlen = assignCode(node->getLeftChild());
if (retcodelen < branchlen)
if (retcodelen < branchlen) {
retcodelen = branchlen;
}
}
if (node->getRightChild()) { // bit '0' branch
code_type c = node->getBinaryCode();
Expand All @@ -449,8 +450,9 @@ class HuffmanModel : public _BASE
}
node->getRightChild()->setBinaryCode(codelen + 1, c);
int branchlen = assignCode(node->getRightChild());
if (retcodelen < branchlen)
if (retcodelen < branchlen) {
retcodelen = branchlen;
}
}
return retcodelen;
}
Expand Down
3 changes: 2 additions & 1 deletion Utilities/DataFlow/src/EPNReceiverDevice.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,9 @@ void EPNReceiverDevice::Run()

while (compatibility::FairMQ13<FairMQDevice>::IsRunning(this)) {
FairMQParts subtimeframeParts;
if (Receive(subtimeframeParts, mInChannelName, 0, 100) <= 0)
if (Receive(subtimeframeParts, mInChannelName, 0, 100) <= 0) {
continue;
}

assert(subtimeframeParts.Size() >= 2);

Expand Down
3 changes: 2 additions & 1 deletion Utilities/DataFlow/src/FLPSenderDevice.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ void FLPSenderDevice::Run()
// - Add the current FLP id to the SubtimeframeMetadata
// - Forward to the EPN the whole subtimeframe
FairMQParts subtimeframeParts;
if (Receive(subtimeframeParts, mInChannelName, 0, 100) <= 0)
if (Receive(subtimeframeParts, mInChannelName, 0, 100) <= 0) {
continue;
}

assert(subtimeframeParts.Size() != 0);
assert(subtimeframeParts.Size() >= 2);
Expand Down
23 changes: 14 additions & 9 deletions Utilities/DataFlow/src/FakeTimeframeBuilder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,34 @@ namespace
{
o2::header::DataDescription lookupDataDescription(const char* key)
{
if (strcmp(key, "RAWDATA") == 0)
if (strcmp(key, "RAWDATA") == 0) {
return o2::header::gDataDescriptionRawData;
else if (strcmp(key, "CLUSTERS") == 0)
} else if (strcmp(key, "CLUSTERS") == 0) {
return o2::header::gDataDescriptionClusters;
else if (strcmp(key, "TRACKS") == 0)
} else if (strcmp(key, "TRACKS") == 0) {
return o2::header::gDataDescriptionTracks;
else if (strcmp(key, "CONFIG") == 0)
} else if (strcmp(key, "CONFIG") == 0) {
return o2::header::gDataDescriptionConfig;
else if (strcmp(key, "INFO") == 0)
} else if (strcmp(key, "INFO") == 0) {
return o2::header::gDataDescriptionInfo;
}
return o2::header::gDataDescriptionInvalid;
}

o2::header::DataOrigin lookupDataOrigin(const char* key)
{
if (strcmp(key, "TPC") == 0)
if (strcmp(key, "TPC") == 0) {
return o2::header::gDataOriginTPC;
if (strcmp(key, "TRD") == 0)
}
if (strcmp(key, "TRD") == 0) {
return o2::header::gDataOriginTRD;
if (strcmp(key, "TOF") == 0)
}
if (strcmp(key, "TOF") == 0) {
return o2::header::gDataOriginTOF;
if (strcmp(key, "ITS") == 0)
}
if (strcmp(key, "ITS") == 0) {
return o2::header::gDataOriginITS;
}
return o2::header::gDataOriginInvalid;
}

Expand Down
3 changes: 2 additions & 1 deletion Utilities/DataFlow/src/SubframeBuilderDevice.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ bool o2::data_flow::SubframeBuilderDevice::BuildAndSendFrame(FairMQParts& inPart
size_t outSize = mMerger->finalise(outBuffer, id);
// In this case we do not have enough subtimeframes for id,
// so we simply return.
if (outSize == 0)
if (outSize == 0) {
return true;
}
// If we reach here, it means we do have enough subtimeframes.

// top level subframe header, the DataHeader is going to be used with
Expand Down
5 changes: 3 additions & 2 deletions Utilities/DataFlow/src/TimeframeValidationTool.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ int main(int argc, char** argv)
while ((c = getopt(argc, argv, "")) != -1) {
switch (c) {
case '?':
if (isprint(optopt))
if (isprint(optopt)) {
fprintf(stderr, "Unknown option `-%c'.\n", optopt);
else
} else {
fprintf(stderr,
"Unknown option character `\\x%x'.\n",
optopt);
}
return 1;
default:
abort();
Expand Down
3 changes: 2 additions & 1 deletion Utilities/DataFlow/src/TimeframeValidatorDevice.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ void o2::data_flow::TimeframeValidatorDevice::Run()
{
while (compatibility::FairMQ13<FairMQDevice>::IsRunning(this)) {
FairMQParts timeframeParts;
if (Receive(timeframeParts, mInChannelName, 0, 100) <= 0)
if (Receive(timeframeParts, mInChannelName, 0, 100) <= 0) {
continue;
}

if (timeframeParts.Size() < 2) {
LOG(ERROR) << "Expecting at least 2 parts\n";
Expand Down
3 changes: 2 additions & 1 deletion Utilities/DataFlow/src/TimeframeWriterDevice.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ void TimeframeWriterDevice::Run()
}

FairMQParts timeframeParts;
if (Receive(timeframeParts, mInChannelName, 0, 100) <= 0)
if (Receive(timeframeParts, mInChannelName, 0, 100) <= 0) {
continue;
}

streamTimeframe(mFile, timeframeParts);
if ((mFile.tellp() > mMaxFileSize) || (streamedTimeframes++ > mMaxTimeframes)) {
Expand Down
3 changes: 2 additions & 1 deletion Utilities/O2MessageMonitor/src/O2MessageMonitor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ void O2MessageMonitor::InitTask()
mIterations = GetConfig()->GetValue<int>("n");
mPayload = GetConfig()->GetValue<std::string>("payload");
std::string tmp = GetConfig()->GetValue<std::string>("name");
if (!tmp.empty())
if (!tmp.empty()) {
mName = tmp;
}
mLimitOutputCharacters = GetConfig()->GetValue<int>("limit");
}

Expand Down
32 changes: 21 additions & 11 deletions Utilities/PCG/include/PCG/pcg_extras.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,9 @@ std::basic_ostream<CharT, Traits>&
if (desired_width > 16) {
out.width(desired_width - 16);
}
if (highpart != 0 || desired_width > 16)
if (highpart != 0 || desired_width > 16) {
out << highpart;
}
CharT oldfill = '\0';
if (highpart != 0) {
out.width(16);
Expand Down Expand Up @@ -168,17 +169,19 @@ std::basic_istream<CharT, Traits>&
{
typename std::basic_istream<CharT, Traits>::sentry s(in);

if (!s)
if (!s) {
return in;
}

constexpr auto BASE = pcg128_t(10ULL);
pcg128_t current(0ULL);
bool did_nothing = true;
bool overflow = false;
for (;;) {
CharT wide_ch = in.get();
if (!in.good())
if (!in.good()) {
break;
}
auto ch = in.narrow(wide_ch, '\0');
if (ch < '0' || ch > '9') {
in.unget();
Expand All @@ -194,8 +197,9 @@ std::basic_istream<CharT, Traits>&

if (did_nothing || overflow) {
in.setstate(std::ios::failbit);
if (overflow)
if (overflow) {
current = ~pcg128_t(0ULL);
}
}

value = current;
Expand Down Expand Up @@ -223,8 +227,9 @@ std::basic_istream<CharT, Traits>&
{
uint32_t value = 0xdecea5edU;
in >> value;
if (!in && value == 0xdecea5edU)
if (!in && value == 0xdecea5edU) {
return in;
}
if (value > uint8_t(~0)) {
in.setstate(std::ios::failbit);
value = ~0U;
Expand Down Expand Up @@ -425,10 +430,11 @@ SrcIter uneven_copy_impl(
src_t value = 0;

while (dest_first != dest_last) {
if ((count++ % SCALE) == 0)
if ((count++ % SCALE) == 0) {
value = *src_first++; // Get more bits
else
} else {
value >>= DEST_BITS; // Move down bits
}

*dest_first++ = dest_t(value); // Truncates, ignores high bits.
}
Expand Down Expand Up @@ -549,8 +555,9 @@ auto bounded_rand(RngType& rng, typename RngType::result_type upper_bound)
rtype threshold = (RngType::max() - RngType::min() + rtype(1) - upper_bound) % upper_bound;
for (;;) {
rtype r = rng() - RngType::min();
if (r >= threshold)
if (r >= threshold) {
return r % upper_bound;
}
}
}

Expand Down Expand Up @@ -599,8 +606,9 @@ class seed_seq_from
template <typename Iter>
void generate(Iter start, Iter finish)
{
for (auto i = start; i != finish; ++i)
for (auto i = start; i != finish; ++i) {
*i = result_type(rng_());
}
}

constexpr size_t size() const
Expand Down Expand Up @@ -654,11 +662,13 @@ std::ostream& operator<<(std::ostream& out, printable_typename<T>)
int status;
char* pretty_name =
abi::__cxa_demangle(implementation_typename, nullptr, nullptr, &status);
if (status == 0)
if (status == 0) {
out << pretty_name;
}
free(static_cast<void*>(pretty_name));
if (status == 0)
if (status == 0) {
return out;
}
#endif
out << implementation_typename;
return out;
Expand Down
38 changes: 25 additions & 13 deletions Utilities/PCG/include/PCG/pcg_random.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,10 +419,11 @@ class engine : protected output_mixin,
public:
result_type operator()()
{
if (output_previous)
if (output_previous) {
return this->output(base_generate0());
else
} else {
return this->output(base_generate());
}
}

result_type operator()(result_type upper_bound)
Expand Down Expand Up @@ -1155,8 +1156,9 @@ struct inside_out : private baseclass {
bool crosses_zero =
forwards ? dist_to_zero <= delta
: (-dist_to_zero) <= delta;
if (!forwards)
if (!forwards) {
delta = -delta;
}
state = baseclass::advance(state, delta, mult, inc);
randval = baseclass::output(state);
return crosses_zero;
Expand Down Expand Up @@ -1212,13 +1214,15 @@ class extended : public baseclass
if (may_tick) {
bool tick = kdd ? (state & tick_mask) == state_type(0u)
: (state >> tick_shift) == state_type(0u);
if (tick)
if (tick) {
advance_table();
}
}
if (may_tock) {
bool tock = state == state_type(0u);
if (tock)
if (tock) {
advance_table();
}
}
return data_[index];
}
Expand Down Expand Up @@ -1348,8 +1352,9 @@ template <bitcount_t table_pow2, bitcount_t advance_pow2,
void extended<table_pow2, advance_pow2, baseclass, extvalclass, kdd>::datainit(
const result_type* data)
{
for (size_t i = 0; i < table_size; ++i)
for (size_t i = 0; i < table_size; ++i) {
data_[i] = data[i];
}
}

template <bitcount_t table_pow2, bitcount_t advance_pow2,
Expand Down Expand Up @@ -1414,8 +1419,9 @@ std::basic_ostream<CharT, Traits>&
<< rng.increment() << space
<< rng.state_;

for (const auto& datum : rng.data_)
for (const auto& datum : rng.data_) {
out << space << datum;
}

out.flags(orig_flags);
out.fill(orig_fill);
Expand All @@ -1434,15 +1440,17 @@ std::basic_istream<CharT, Traits>&
auto& base_rng = static_cast<baseclass&>(new_rng);
in >> base_rng;

if (in.fail())
if (in.fail()) {
return in;
}

auto orig_flags = in.flags(std::ios_base::dec | std::ios_base::skipws);

for (auto& datum : new_rng.data_) {
in >> datum;
if (in.fail())
if (in.fail()) {
goto bail;
}
}

rng = new_rng;
Expand Down Expand Up @@ -1509,21 +1517,25 @@ void extended<table_pow2, advance_pow2, baseclass, extvalclass, kdd>::advance(
state_type adv_mask =
baseclass::is_mcg ? tick_mask << 2 : tick_mask;
state_type next_advance_distance = this->distance(zero, adv_mask);
if (!forwards)
if (!forwards) {
next_advance_distance = (-next_advance_distance) & tick_mask;
}
if (next_advance_distance < (distance & tick_mask)) {
++ticks;
}
if (ticks)
if (ticks) {
advance_table(ticks, forwards);
}
}
if (forwards) {
if (may_tock && this->distance(zero) <= distance)
if (may_tock && this->distance(zero) <= distance) {
advance_table();
}
baseclass::advance(distance);
} else {
if (may_tock && -(this->distance(zero)) <= distance)
if (may_tock && -(this->distance(zero)) <= distance) {
advance_table(state_type(1U), false);
}
baseclass::advance(-distance);
}
}
Expand Down
6 changes: 4 additions & 2 deletions Utilities/Publishers/src/DataPublisherDevice.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ bool DataPublisherDevice::HandleO2LogicalBlock(const byte* headerBuffer,
// not handled in O2Device::ForEach at the moment
// indicate that the block has not been processed by a 'false'
if (!dataHeader ||
(dataHeader->dataDescription) != o2::header::gDataDescriptionHeartbeatFrame)
(dataHeader->dataDescription) != o2::header::gDataDescriptionHeartbeatFrame) {
return false;
}

if (!hbfEnvelope) {
LOG(ERROR) << "no heartbeat frame envelope header found";
Expand Down Expand Up @@ -190,8 +191,9 @@ bool DataPublisherDevice::AppendFile(const char* name, std::vector<o2::byte>& bu
{
bool result = true;
std::ifstream ifile(name, std::ifstream::binary);
if (ifile.bad())
if (ifile.bad()) {
return false;
}

// get length of file:
ifile.seekg(0, ifile.end);
Expand Down
Loading