Swap "if" and "else" code blocks in slot_new() to improve readability.

No behavior change.
This commit is contained in:
Alexandre Ratchov 2019-07-10 11:43:45 +02:00
parent e21b26a56f
commit e6579625a0
1 changed files with 16 additions and 15 deletions

View File

@ -1600,28 +1600,29 @@ slot_new(struct dev *d, struct opt *opt, char *who,
bestidx = i; bestidx = i;
} }
} }
if (bestidx == DEV_NSLOT) { if (bestidx != DEV_NSLOT) {
if (log_level >= 1) { s = d->slot + bestidx;
s->vol = MIDI_MAXCTL;
strlcpy(s->name, name, SLOT_NAMEMAX);
s->serial = d->serial++;
s->unit = unit;
#ifdef DEBUG
if (log_level >= 3) {
log_puts(name); log_puts(name);
log_putu(unit); log_putu(unit);
log_puts(": out of sub-device slots\n"); log_puts(": overwritten slot ");
log_putu(bestidx);
log_puts("\n");
} }
return NULL; #endif
goto found;
} }
s = d->slot + bestidx; if (log_level >= 1) {
s->vol = MIDI_MAXCTL;
strlcpy(s->name, name, SLOT_NAMEMAX);
s->serial = d->serial++;
s->unit = unit;
#ifdef DEBUG
if (log_level >= 3) {
log_puts(name); log_puts(name);
log_putu(unit); log_putu(unit);
log_puts(": overwritten slot "); log_puts(": out of sub-device slots\n");
log_putu(bestidx);
log_puts("\n");
} }
#endif return NULL;
found: found:
if ((mode & MODE_REC) && (opt->mode & MODE_MON)) { if ((mode & MODE_REC) && (opt->mode & MODE_MON)) {