added a safeguard

sipo
Ondřej Hruška 6 years ago
parent c4cc3bb9ce
commit 137619d942
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 10
      framework/unit_registry.c

@ -326,20 +326,26 @@ bool ureg_finalize_all_init(void)
while (li != NULL) {
Unit *const pUnit = &li->unit;
if (pUnit->status == E_SUCCESS) {
dbg("! Unit seems already loaded, skipping");
} else {
pUnit->status = pUnit->driver->init(pUnit);
if (pUnit->status != E_SUCCESS) {
dbg("!!! error initing unit %s: %s", pUnit->name, error_get_message(pUnit->status));
dbg("!!! error initing unit %s: %s", pUnit->name,
error_get_message(pUnit->status));
}
// try to assign unique callsigns
// FIXME this is wrong, sometimes leads to duplicate CS
if (pUnit->callsign == 0) {
pUnit->callsign = callsign++;
} else {
}
else {
if (pUnit->callsign >= callsign) {
callsign = (uint8_t) (pUnit->callsign + 1);
}
}
}
suc &= (pUnit->status == E_SUCCESS);
li = li->next;

Loading…
Cancel
Save