Automated style fixes in order to bring the code a little bit closer to compliance with MISRA C++ rules. No changes in logic.

This commit is contained in:
Pavel Kirienko
2014-03-25 03:04:36 +04:00
parent cce657e1fe
commit 0cc627016a
64 changed files with 777 additions and 283 deletions
@@ -35,11 +35,15 @@ GlobalDataTypeRegistry::RegistResult GlobalDataTypeRegistry::remove(Entry* dtd)
return RegistResultInvalidParams;
}
if (isFrozen())
{
return RegistResultFrozen;
}
List* list = selectList(dtd->descriptor.getKind());
if (!list)
{
return RegistResultInvalidParams;
}
list->remove(dtd); // If this call came from regist<>(), that would be enough
Entry* p = list->get(); // But anyway
@@ -47,7 +51,9 @@ GlobalDataTypeRegistry::RegistResult GlobalDataTypeRegistry::remove(Entry* dtd)
{
Entry* const next = p->getNextListNode();
if (p->descriptor.match(dtd->descriptor.getKind(), dtd->descriptor.getFullName()))
{
list->remove(p);
}
p = next;
}
return RegistResultOk;
@@ -61,20 +67,28 @@ GlobalDataTypeRegistry::RegistResult GlobalDataTypeRegistry::registImpl(Entry* d
return RegistResultInvalidParams;
}
if (isFrozen())
{
return RegistResultFrozen;
}
List* list = selectList(dtd->descriptor.getKind());
if (!list)
{
return RegistResultInvalidParams;
}
{ // Collision check
Entry* p = list->get();
while (p)
{
if (p->descriptor.getID() == dtd->descriptor.getID()) // ID collision
{
return RegistResultCollision;
}
if (!std::strcmp(p->descriptor.getFullName(), dtd->descriptor.getFullName())) // Name collision
{
return RegistResultCollision;
}
p = p->getNextListNode();
}
}
@@ -132,7 +146,9 @@ const DataTypeDescriptor* GlobalDataTypeRegistry::find(DataTypeKind kind, const
while (p)
{
if (p->descriptor.match(kind, name))
{
return &p->descriptor;
}
p = p->getNextListNode();
}
return NULL;
@@ -150,7 +166,9 @@ const DataTypeDescriptor* GlobalDataTypeRegistry::find(DataTypeKind kind, DataTy
while (p)
{
if (p->descriptor.match(kind, dtid))
{
return &p->descriptor;
}
p = p->getNextListNode();
}
return NULL;
@@ -180,23 +198,31 @@ DataTypeSignature GlobalDataTypeRegistry::computeAggregateSignature(DataTypeKind
if (inout_id_mask[dtid])
{
if (signature_initialized)
{
signature.extend(desc.getSignature());
}
else
{
signature = DataTypeSignature(desc.getSignature());
}
signature_initialized = true;
}
assert(prev_dtid < dtid); // Making sure that list is ordered properly
prev_dtid++;
while (prev_dtid < dtid)
{
inout_id_mask[prev_dtid++] = false; // Erasing bits for missing types
}
assert(prev_dtid == dtid);
p = p->getNextListNode();
}
prev_dtid++;
while (prev_dtid <= DataTypeID::Max)
{
inout_id_mask[prev_dtid++] = false;
}
return signature;
}
+18
View File
@@ -70,11 +70,15 @@ bool DeadlineScheduler::doesExist(const DeadlineHandler* mdh) const
{
#if UAVCAN_DEBUG
if (prev_deadline > p->getDeadline()) // Self check
{
std::abort();
}
prev_deadline = p->getDeadline();
#endif
if (p == mdh)
{
return true;
}
p = p->getNextListNode();
}
return false;
@@ -86,15 +90,21 @@ MonotonicTime DeadlineScheduler::pollAndGetMonotonicTime(ISystemClock& sysclock)
{
DeadlineHandler* const mdh = handlers_.get();
if (!mdh)
{
return sysclock.getMonotonic();
}
#if UAVCAN_DEBUG
if (mdh->getNextListNode()) // Order check
{
assert(mdh->getDeadline() <= mdh->getNextListNode()->getDeadline());
}
#endif
const MonotonicTime ts = sysclock.getMonotonic();
if (ts < mdh->getDeadline())
{
return ts;
}
handlers_.remove(mdh);
mdh->handleDeadline(ts); // This handler can be re-registered immediately
@@ -107,7 +117,9 @@ MonotonicTime DeadlineScheduler::getEarliestDeadline() const
{
const DeadlineHandler* const mdh = handlers_.get();
if (mdh)
{
return mdh->getDeadline();
}
return MonotonicTime::getMax();
}
@@ -121,7 +133,9 @@ MonotonicTime Scheduler::computeDispatcherSpinDeadline(MonotonicTime spin_deadli
if (earliest > ts)
{
if (ts - earliest > deadline_resolution_)
{
return ts + deadline_resolution_;
}
}
return earliest;
}
@@ -146,12 +160,16 @@ int Scheduler::spin(MonotonicTime deadline)
const MonotonicTime dl = computeDispatcherSpinDeadline(deadline);
retval = dispatcher_.spin(dl);
if (retval < 0)
{
break;
}
const MonotonicTime ts = deadline_scheduler_.pollAndGetMonotonicTime(getSystemClock());
pollCleanup(ts, retval);
if (ts >= deadline)
{
break;
}
}
return retval;
}
+2
View File
@@ -15,7 +15,9 @@ void Timer::handleDeadline(MonotonicTime current)
const MonotonicTime scheduled_time = getDeadline();
if (period_ < MonotonicDuration::getInfinite())
{
startWithDeadline(scheduled_time + period_);
}
// Application can re-register the timer with different params, it's OK
handleTimerEvent(TimerEvent(scheduled_time, current));