added a safeguard

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

@ -326,18 +326,24 @@ bool ureg_finalize_all_init(void)
while (li != NULL) {
Unit *const pUnit = &li->unit;
pUnit->status = pUnit->driver->init(pUnit);
if (pUnit->status != E_SUCCESS) {
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++;
if (pUnit->status == E_SUCCESS) {
dbg("! Unit seems already loaded, skipping");
} else {
if (pUnit->callsign >= callsign) {
callsign = (uint8_t) (pUnit->callsign + 1);
pUnit->status = pUnit->driver->init(pUnit);
if (pUnit->status != E_SUCCESS) {
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 {
if (pUnit->callsign >= callsign) {
callsign = (uint8_t) (pUnit->callsign + 1);
}
}
}

Loading…
Cancel
Save