diff options
author | 2019-07-10 14:24:42 +0000 | |
---|---|---|
committer | 2019-07-10 14:24:42 +0000 | |
commit | 5be96c4d4ae7d4c695a897acfc7c2846b65e88f6 (patch) | |
tree | a080fc9a2805e15ed958508ac194d12b8c215af2 | |
parent | Slot name can't be empty. So, no need to check if it is empty. (diff) | |
download | wireguard-openbsd-5be96c4d4ae7d4c695a897acfc7c2846b65e88f6.tar.xz wireguard-openbsd-5be96c4d4ae7d4c695a897acfc7c2846b65e88f6.zip |
Swap "if" and "else" code blocks in slot_new() to improve readability.
No behavior change.
-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)) { |