From: ratchov Date: Thu, 28 Jan 2021 11:10:00 +0000 (+0000) Subject: In slot_xxx(), store dev pointer in local variable X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=758b5165ac53b1f1b45995941f1d5f6fa08bf644;p=openbsd In slot_xxx(), store dev pointer in local variable This removes many redundant dereferences to obtain the dev pointer from the slot stucture and makes the source slightly more readable. No behavior change. --- diff --git a/usr.bin/sndiod/dev.c b/usr.bin/sndiod/dev.c index e416f33f0f8..e3ce842711d 100644 --- a/usr.bin/sndiod/dev.c +++ b/usr.bin/sndiod/dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev.c,v 1.80 2021/01/28 11:06:58 ratchov Exp $ */ +/* $OpenBSD: dev.c,v 1.81 2021/01/28 11:10:00 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov * @@ -2086,6 +2086,7 @@ slot_ready(struct slot *s) void slot_start(struct slot *s) { + struct dev *d = s->dev; #ifdef DEBUG if (s->pstate != SLOT_INIT) { slot_log(s); @@ -2098,7 +2099,7 @@ slot_start(struct slot *s) log_puts(": playing "); aparams_log(&s->par); log_puts(" -> "); - aparams_log(&s->dev->par); + aparams_log(&d->par); log_puts("\n"); } } @@ -2108,7 +2109,7 @@ slot_start(struct slot *s) log_puts(": recording "); aparams_log(&s->par); log_puts(" <- "); - aparams_log(&s->dev->par); + aparams_log(&d->par); log_puts("\n"); } } @@ -2119,7 +2120,7 @@ slot_start(struct slot *s) /* * N-th recorded block is the N-th played block */ - s->sub.prime = -dev_getpos(s->dev) / s->dev->round; + s->sub.prime = -dev_getpos(d) / d->round; } s->skip = 0; @@ -2127,7 +2128,7 @@ slot_start(struct slot *s) * get the current position, the origin is when the first sample * played and/or recorded */ - s->delta = dev_getpos(s->dev) * (int)s->round / (int)s->dev->round; + s->delta = dev_getpos(d) * (int)s->round / (int)d->round; s->delta_rem = 0; if (s->mode & MODE_PLAY) { @@ -2145,16 +2146,10 @@ void slot_detach(struct slot *s) { struct slot **ps; - struct dev *d; + struct dev *d = s->dev; long long pos; -#ifdef DEBUG - if (log_level >= 3) { - slot_log(s); - log_puts(": detaching\n"); - } -#endif - for (ps = &s->dev->slot_list; *ps != s; ps = &(*ps)->next) { + for (ps = &d->slot_list; *ps != s; ps = &(*ps)->next) { #ifdef DEBUG if (*ps == NULL) { slot_log(s); @@ -2165,8 +2160,6 @@ slot_detach(struct slot *s) } *ps = s->next; - d = s->dev; - /* * adjust clock, go back d->delta ticks so that slot_attach() * could be called with the resulting state @@ -2194,7 +2187,7 @@ slot_detach(struct slot *s) } #endif if (s->mode & MODE_PLAY) - dev_mix_adjvol(s->dev); + dev_mix_adjvol(d); } /*