Skip to content

Commit a2f9cc7

Browse files
authored
Utilities: add braces to single statements (#4530)
1 parent 20c9a95 commit a2f9cc7

24 files changed

Lines changed: 288 additions & 144 deletions

Utilities/DataCompression/include/DataCompression/HuffmanCodec.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,9 @@ class HuffmanModel : public _BASE
436436
}
437437
node->getLeftChild()->setBinaryCode(codelen + 1, c);
438438
int branchlen = assignCode(node->getLeftChild());
439-
if (retcodelen < branchlen)
439+
if (retcodelen < branchlen) {
440440
retcodelen = branchlen;
441+
}
441442
}
442443
if (node->getRightChild()) { // bit '0' branch
443444
code_type c = node->getBinaryCode();
@@ -449,8 +450,9 @@ class HuffmanModel : public _BASE
449450
}
450451
node->getRightChild()->setBinaryCode(codelen + 1, c);
451452
int branchlen = assignCode(node->getRightChild());
452-
if (retcodelen < branchlen)
453+
if (retcodelen < branchlen) {
453454
retcodelen = branchlen;
455+
}
454456
}
455457
return retcodelen;
456458
}

Utilities/DataFlow/src/EPNReceiverDevice.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ void EPNReceiverDevice::Run()
9494

9595
while (compatibility::FairMQ13<FairMQDevice>::IsRunning(this)) {
9696
FairMQParts subtimeframeParts;
97-
if (Receive(subtimeframeParts, mInChannelName, 0, 100) <= 0)
97+
if (Receive(subtimeframeParts, mInChannelName, 0, 100) <= 0) {
9898
continue;
99+
}
99100

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

Utilities/DataFlow/src/FLPSenderDevice.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ void FLPSenderDevice::Run()
5050
// - Add the current FLP id to the SubtimeframeMetadata
5151
// - Forward to the EPN the whole subtimeframe
5252
FairMQParts subtimeframeParts;
53-
if (Receive(subtimeframeParts, mInChannelName, 0, 100) <= 0)
53+
if (Receive(subtimeframeParts, mInChannelName, 0, 100) <= 0) {
5454
continue;
55+
}
5556

5657
assert(subtimeframeParts.Size() != 0);
5758
assert(subtimeframeParts.Size() >= 2);

Utilities/DataFlow/src/FakeTimeframeBuilder.cxx

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,34 @@ namespace
2525
{
2626
o2::header::DataDescription lookupDataDescription(const char* key)
2727
{
28-
if (strcmp(key, "RAWDATA") == 0)
28+
if (strcmp(key, "RAWDATA") == 0) {
2929
return o2::header::gDataDescriptionRawData;
30-
else if (strcmp(key, "CLUSTERS") == 0)
30+
} else if (strcmp(key, "CLUSTERS") == 0) {
3131
return o2::header::gDataDescriptionClusters;
32-
else if (strcmp(key, "TRACKS") == 0)
32+
} else if (strcmp(key, "TRACKS") == 0) {
3333
return o2::header::gDataDescriptionTracks;
34-
else if (strcmp(key, "CONFIG") == 0)
34+
} else if (strcmp(key, "CONFIG") == 0) {
3535
return o2::header::gDataDescriptionConfig;
36-
else if (strcmp(key, "INFO") == 0)
36+
} else if (strcmp(key, "INFO") == 0) {
3737
return o2::header::gDataDescriptionInfo;
38+
}
3839
return o2::header::gDataDescriptionInvalid;
3940
}
4041

4142
o2::header::DataOrigin lookupDataOrigin(const char* key)
4243
{
43-
if (strcmp(key, "TPC") == 0)
44+
if (strcmp(key, "TPC") == 0) {
4445
return o2::header::gDataOriginTPC;
45-
if (strcmp(key, "TRD") == 0)
46+
}
47+
if (strcmp(key, "TRD") == 0) {
4648
return o2::header::gDataOriginTRD;
47-
if (strcmp(key, "TOF") == 0)
49+
}
50+
if (strcmp(key, "TOF") == 0) {
4851
return o2::header::gDataOriginTOF;
49-
if (strcmp(key, "ITS") == 0)
52+
}
53+
if (strcmp(key, "ITS") == 0) {
5054
return o2::header::gDataOriginITS;
55+
}
5156
return o2::header::gDataOriginInvalid;
5257
}
5358

Utilities/DataFlow/src/SubframeBuilderDevice.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ bool o2::data_flow::SubframeBuilderDevice::BuildAndSendFrame(FairMQParts& inPart
8686
size_t outSize = mMerger->finalise(outBuffer, id);
8787
// In this case we do not have enough subtimeframes for id,
8888
// so we simply return.
89-
if (outSize == 0)
89+
if (outSize == 0) {
9090
return true;
91+
}
9192
// If we reach here, it means we do have enough subtimeframes.
9293

9394
// top level subframe header, the DataHeader is going to be used with

Utilities/DataFlow/src/TimeframeValidationTool.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ int main(int argc, char** argv)
2828
while ((c = getopt(argc, argv, "")) != -1) {
2929
switch (c) {
3030
case '?':
31-
if (isprint(optopt))
31+
if (isprint(optopt)) {
3232
fprintf(stderr, "Unknown option `-%c'.\n", optopt);
33-
else
33+
} else {
3434
fprintf(stderr,
3535
"Unknown option character `\\x%x'.\n",
3636
optopt);
37+
}
3738
return 1;
3839
default:
3940
abort();

Utilities/DataFlow/src/TimeframeValidatorDevice.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ void o2::data_flow::TimeframeValidatorDevice::Run()
4343
{
4444
while (compatibility::FairMQ13<FairMQDevice>::IsRunning(this)) {
4545
FairMQParts timeframeParts;
46-
if (Receive(timeframeParts, mInChannelName, 0, 100) <= 0)
46+
if (Receive(timeframeParts, mInChannelName, 0, 100) <= 0) {
4747
continue;
48+
}
4849

4950
if (timeframeParts.Size() < 2) {
5051
LOG(ERROR) << "Expecting at least 2 parts\n";

Utilities/DataFlow/src/TimeframeWriterDevice.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ void TimeframeWriterDevice::Run()
7070
}
7171

7272
FairMQParts timeframeParts;
73-
if (Receive(timeframeParts, mInChannelName, 0, 100) <= 0)
73+
if (Receive(timeframeParts, mInChannelName, 0, 100) <= 0) {
7474
continue;
75+
}
7576

7677
streamTimeframe(mFile, timeframeParts);
7778
if ((mFile.tellp() > mMaxFileSize) || (streamedTimeframes++ > mMaxTimeframes)) {

Utilities/O2MessageMonitor/src/O2MessageMonitor.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ void O2MessageMonitor::InitTask()
4545
mIterations = GetConfig()->GetValue<int>("n");
4646
mPayload = GetConfig()->GetValue<std::string>("payload");
4747
std::string tmp = GetConfig()->GetValue<std::string>("name");
48-
if (!tmp.empty())
48+
if (!tmp.empty()) {
4949
mName = tmp;
50+
}
5051
mLimitOutputCharacters = GetConfig()->GetValue<int>("limit");
5152
}
5253

Utilities/PCG/include/PCG/pcg_extras.hpp

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,9 @@ std::basic_ostream<CharT, Traits>&
132132
if (desired_width > 16) {
133133
out.width(desired_width - 16);
134134
}
135-
if (highpart != 0 || desired_width > 16)
135+
if (highpart != 0 || desired_width > 16) {
136136
out << highpart;
137+
}
137138
CharT oldfill = '\0';
138139
if (highpart != 0) {
139140
out.width(16);
@@ -168,17 +169,19 @@ std::basic_istream<CharT, Traits>&
168169
{
169170
typename std::basic_istream<CharT, Traits>::sentry s(in);
170171

171-
if (!s)
172+
if (!s) {
172173
return in;
174+
}
173175

174176
constexpr auto BASE = pcg128_t(10ULL);
175177
pcg128_t current(0ULL);
176178
bool did_nothing = true;
177179
bool overflow = false;
178180
for (;;) {
179181
CharT wide_ch = in.get();
180-
if (!in.good())
182+
if (!in.good()) {
181183
break;
184+
}
182185
auto ch = in.narrow(wide_ch, '\0');
183186
if (ch < '0' || ch > '9') {
184187
in.unget();
@@ -194,8 +197,9 @@ std::basic_istream<CharT, Traits>&
194197

195198
if (did_nothing || overflow) {
196199
in.setstate(std::ios::failbit);
197-
if (overflow)
200+
if (overflow) {
198201
current = ~pcg128_t(0ULL);
202+
}
199203
}
200204

201205
value = current;
@@ -223,8 +227,9 @@ std::basic_istream<CharT, Traits>&
223227
{
224228
uint32_t value = 0xdecea5edU;
225229
in >> value;
226-
if (!in && value == 0xdecea5edU)
230+
if (!in && value == 0xdecea5edU) {
227231
return in;
232+
}
228233
if (value > uint8_t(~0)) {
229234
in.setstate(std::ios::failbit);
230235
value = ~0U;
@@ -425,10 +430,11 @@ SrcIter uneven_copy_impl(
425430
src_t value = 0;
426431

427432
while (dest_first != dest_last) {
428-
if ((count++ % SCALE) == 0)
433+
if ((count++ % SCALE) == 0) {
429434
value = *src_first++; // Get more bits
430-
else
435+
} else {
431436
value >>= DEST_BITS; // Move down bits
437+
}
432438

433439
*dest_first++ = dest_t(value); // Truncates, ignores high bits.
434440
}
@@ -549,8 +555,9 @@ auto bounded_rand(RngType& rng, typename RngType::result_type upper_bound)
549555
rtype threshold = (RngType::max() - RngType::min() + rtype(1) - upper_bound) % upper_bound;
550556
for (;;) {
551557
rtype r = rng() - RngType::min();
552-
if (r >= threshold)
558+
if (r >= threshold) {
553559
return r % upper_bound;
560+
}
554561
}
555562
}
556563

@@ -599,8 +606,9 @@ class seed_seq_from
599606
template <typename Iter>
600607
void generate(Iter start, Iter finish)
601608
{
602-
for (auto i = start; i != finish; ++i)
609+
for (auto i = start; i != finish; ++i) {
603610
*i = result_type(rng_());
611+
}
604612
}
605613

606614
constexpr size_t size() const
@@ -654,11 +662,13 @@ std::ostream& operator<<(std::ostream& out, printable_typename<T>)
654662
int status;
655663
char* pretty_name =
656664
abi::__cxa_demangle(implementation_typename, nullptr, nullptr, &status);
657-
if (status == 0)
665+
if (status == 0) {
658666
out << pretty_name;
667+
}
659668
free(static_cast<void*>(pretty_name));
660-
if (status == 0)
669+
if (status == 0) {
661670
return out;
671+
}
662672
#endif
663673
out << implementation_typename;
664674
return out;

0 commit comments

Comments
 (0)