Brenton/curly braces (#1971)
* fix formatting * properly adjust various lines breakup multiple statements onto multiple lines * insert {} around if, for, etc.
This commit is contained in:
parent
e6802690b8
commit
f73e51e94c
57 changed files with 2247 additions and 1082 deletions
|
@ -69,10 +69,11 @@ unsigned int Multicaster::gather(const Address &queryingPeer,uint64_t nwid,const
|
|||
unsigned int added = 0,i,k,rptr,totalKnown = 0;
|
||||
uint64_t a,picked[(ZT_PROTO_MAX_PACKET_LENGTH / 5) + 2];
|
||||
|
||||
if (!limit)
|
||||
if (!limit) {
|
||||
return 0;
|
||||
else if (limit > 0xffff)
|
||||
} else if (limit > 0xffff) {
|
||||
limit = 0xffff;
|
||||
}
|
||||
|
||||
const unsigned int totalAt = appendTo.size();
|
||||
appendTo.addSize(4); // sizeof(uint32_t)
|
||||
|
@ -133,12 +134,14 @@ std::vector<Address> Multicaster::getMembers(uint64_t nwid,const MulticastGroup
|
|||
std::vector<Address> ls;
|
||||
Mutex::Lock _l(_groups_m);
|
||||
const MulticastGroupStatus *s = _groups.get(Multicaster::Key(nwid,mg));
|
||||
if (!s)
|
||||
if (!s) {
|
||||
return ls;
|
||||
}
|
||||
for(std::vector<MulticastGroupMember>::const_reverse_iterator m(s->members.rbegin());m!=s->members.rend();++m) {
|
||||
ls.push_back(m->address);
|
||||
if (ls.size() >= limit)
|
||||
if (ls.size() >= limit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ls;
|
||||
}
|
||||
|
@ -193,7 +196,9 @@ void Multicaster::send(
|
|||
outp.append((uint32_t)mg.adi());
|
||||
outp.append((uint16_t)etherType);
|
||||
outp.append(data,len);
|
||||
if (!network->config().disableCompression()) outp.compress();
|
||||
if (!network->config().disableCompression()) {
|
||||
outp.compress();
|
||||
}
|
||||
outp.armor(bestMulticastReplicator->key(),true,bestMulticastReplicator->aesKeysIfSupported());
|
||||
bestMulticastReplicatorPath->send(RR,tPtr,outp.data(),outp.size(),now);
|
||||
return;
|
||||
|
@ -208,12 +213,14 @@ void Multicaster::send(
|
|||
|
||||
if (!gs.members.empty()) {
|
||||
// Allocate a memory buffer if group is monstrous
|
||||
if (gs.members.size() > (sizeof(idxbuf) / sizeof(unsigned long)))
|
||||
if (gs.members.size() > (sizeof(idxbuf) / sizeof(unsigned long))) {
|
||||
indexes = new unsigned long[gs.members.size()];
|
||||
}
|
||||
|
||||
// Generate a random permutation of member indexes
|
||||
for(unsigned long i=0;i<gs.members.size();++i)
|
||||
for(unsigned long i=0;i<gs.members.size();++i) {
|
||||
indexes[i] = i;
|
||||
}
|
||||
for(unsigned long i=(unsigned long)gs.members.size()-1;i>0;--i) {
|
||||
unsigned long j = (unsigned long)RR->node->prng() % (i + 1);
|
||||
unsigned long tmp = indexes[j];
|
||||
|
@ -248,8 +255,9 @@ void Multicaster::send(
|
|||
for(unsigned int i=0;i<activeBridgeCount;++i) {
|
||||
if ((activeBridges[i] != RR->identity.address())&&(activeBridges[i] != origin)) {
|
||||
out.sendOnly(RR,tPtr,activeBridges[i]); // optimization: don't use dedup log if it's a one-pass send
|
||||
if (++count >= limit)
|
||||
if (++count >= limit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -276,16 +284,18 @@ void Multicaster::send(
|
|||
unsigned int numExplicitGatherPeers = 0;
|
||||
|
||||
SharedPtr<Peer> bestRoot(RR->topology->getUpstreamPeer());
|
||||
if (bestRoot)
|
||||
if (bestRoot) {
|
||||
explicitGatherPeers[numExplicitGatherPeers++] = bestRoot->address();
|
||||
}
|
||||
|
||||
explicitGatherPeers[numExplicitGatherPeers++] = network->controller();
|
||||
|
||||
Address ac[ZT_MAX_NETWORK_SPECIALISTS];
|
||||
const unsigned int accnt = network->config().alwaysContactAddresses(ac);
|
||||
unsigned int shuffled[ZT_MAX_NETWORK_SPECIALISTS];
|
||||
for(unsigned int i=0;i<accnt;++i)
|
||||
for(unsigned int i=0;i<accnt;++i) {
|
||||
shuffled[i] = i;
|
||||
}
|
||||
for(unsigned int i=0,k=accnt>>1;i<k;++i) {
|
||||
const uint64_t x = RR->node->prng();
|
||||
const unsigned int x1 = shuffled[(unsigned int)x % accnt];
|
||||
|
@ -296,16 +306,18 @@ void Multicaster::send(
|
|||
}
|
||||
for(unsigned int i=0;i<accnt;++i) {
|
||||
explicitGatherPeers[numExplicitGatherPeers++] = ac[shuffled[i]];
|
||||
if (numExplicitGatherPeers == 16)
|
||||
if (numExplicitGatherPeers == 16) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<Address> anchors(network->config().anchors());
|
||||
for(std::vector<Address>::const_iterator a(anchors.begin());a!=anchors.end();++a) {
|
||||
if (*a != RR->identity.address()) {
|
||||
explicitGatherPeers[numExplicitGatherPeers++] = *a;
|
||||
if (numExplicitGatherPeers == 16)
|
||||
if (numExplicitGatherPeers == 16) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -317,8 +329,9 @@ void Multicaster::send(
|
|||
mg.mac().appendTo(outp);
|
||||
outp.append((uint32_t)mg.adi());
|
||||
outp.append((uint32_t)gatherLimit);
|
||||
if (com)
|
||||
if (com) {
|
||||
com->serialize(outp);
|
||||
}
|
||||
RR->node->expectReplyTo(outp.packetId());
|
||||
RR->sw->send(tPtr,outp,true);
|
||||
}
|
||||
|
@ -340,16 +353,18 @@ void Multicaster::send(
|
|||
data,
|
||||
len);
|
||||
|
||||
if (origin)
|
||||
if (origin) {
|
||||
out.logAsSent(origin);
|
||||
}
|
||||
|
||||
unsigned int count = 0;
|
||||
|
||||
for(unsigned int i=0;i<activeBridgeCount;++i) {
|
||||
if (activeBridges[i] != RR->identity.address()) {
|
||||
out.sendAndLog(RR,tPtr,activeBridges[i]);
|
||||
if (++count >= limit)
|
||||
if (++count >= limit) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -365,8 +380,9 @@ void Multicaster::send(
|
|||
} catch ( ... ) {} // this is a sanity check to catch any failures and make sure indexes[] still gets deleted
|
||||
|
||||
// Free allocated memory buffer if any
|
||||
if (indexes != idxbuf)
|
||||
if (indexes != idxbuf) {
|
||||
delete [] indexes;
|
||||
}
|
||||
}
|
||||
|
||||
void Multicaster::clean(int64_t now)
|
||||
|
@ -377,9 +393,11 @@ void Multicaster::clean(int64_t now)
|
|||
Hashtable<Multicaster::Key,MulticastGroupStatus>::Iterator mm(_groups);
|
||||
while (mm.next(k,s)) {
|
||||
for(std::list<OutboundMulticast>::iterator tx(s->txQueue.begin());tx!=s->txQueue.end();) {
|
||||
if ((tx->expired(now))||(tx->atLimit()))
|
||||
if ((tx->expired(now))||(tx->atLimit())) {
|
||||
s->txQueue.erase(tx++);
|
||||
else ++tx;
|
||||
} else {
|
||||
++tx;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long count = 0;
|
||||
|
@ -411,8 +429,9 @@ void Multicaster::_add(void *tPtr,int64_t now,uint64_t nwid,const MulticastGroup
|
|||
// assumes _groups_m is locked
|
||||
|
||||
// Do not add self -- even if someone else returns it
|
||||
if (member == RR->identity.address())
|
||||
if (member == RR->identity.address()) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<MulticastGroupMember>::iterator m(std::lower_bound(gs.members.begin(),gs.members.end(),member));
|
||||
if (m != gs.members.end()) {
|
||||
|
@ -426,13 +445,15 @@ void Multicaster::_add(void *tPtr,int64_t now,uint64_t nwid,const MulticastGroup
|
|||
}
|
||||
|
||||
for(std::list<OutboundMulticast>::iterator tx(gs.txQueue.begin());tx!=gs.txQueue.end();) {
|
||||
if (tx->atLimit())
|
||||
if (tx->atLimit()) {
|
||||
gs.txQueue.erase(tx++);
|
||||
else {
|
||||
} else {
|
||||
tx->sendIfNew(RR,tPtr,member);
|
||||
if (tx->atLimit())
|
||||
if (tx->atLimit()) {
|
||||
gs.txQueue.erase(tx++);
|
||||
else ++tx;
|
||||
} else {
|
||||
++tx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue