diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2019-07-10 14:24:43 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2019-07-10 14:24:43 +0000 |
commit | 1a950ca31e6f29a680891123d74bd42caa181120 (patch) | |
tree | 458f65e32e5ce06f2363adee5905d6cf973f4e42 /usr.bin/sndiod | |
parent | 9079b2d1bd2c8d931e36f9e50225d6d13f201ac4 (diff) |
Swap "if" and "else" code blocks in slot_new() to improve readability.
No behavior change.
Diffstat (limited to 'usr.bin/sndiod')
-rw-r--r-- | usr.bin/sndiod/dev.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/usr.bin/sndiod/dev.c b/usr.bin/sndiod/dev.c index 1c8e7c77a06..d7bd18b4103 100644 --- a/usr.bin/sndiod/dev.c +++ b/usr.bin/sndiod/dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev.c,v 1.50 2019/07/10 14:22:52 ratchov Exp $ */ +/* $OpenBSD: dev.c,v 1.51 2019/07/10 14:24:42 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov <alex@caoua.org> * @@ -1598,28 +1598,29 @@ slot_new(struct dev *d, struct opt *opt, char *who, bestidx = i; } } - if (bestidx == DEV_NSLOT) { - if (log_level >= 1) { + if (bestidx != DEV_NSLOT) { + 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_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; - s->vol = MIDI_MAXCTL; - strlcpy(s->name, name, SLOT_NAMEMAX); - s->serial = d->serial++; - s->unit = unit; -#ifdef DEBUG - if (log_level >= 3) { + if (log_level >= 1) { log_puts(name); log_putu(unit); - log_puts(": overwritten slot "); - log_putu(bestidx); - log_puts("\n"); + log_puts(": out of sub-device slots\n"); } -#endif + return NULL; found: if ((mode & MODE_REC) && (opt->mode & MODE_MON)) { |