summaryrefslogtreecommitdiff
path: root/usr.bin/aucat/aucat.c
diff options
context:
space:
mode:
authorAlexandre Ratchov <ratchov@cvs.openbsd.org>2016-05-27 15:46:42 +0000
committerAlexandre Ratchov <ratchov@cvs.openbsd.org>2016-05-27 15:46:42 +0000
commit635c92eef75e489974d951ff7e6c531dfc612452 (patch)
treea0e0b476265408085bc92a1f4327f3dcdcad07ce /usr.bin/aucat/aucat.c
parent4e22ee08661b3746ea972781154209a3d0083ce2 (diff)
Simplify slot_fill() and slot_flush(). No behaviour change
Diffstat (limited to 'usr.bin/aucat/aucat.c')
-rw-r--r--usr.bin/aucat/aucat.c20
1 files changed, 8 insertions, 12 deletions
diff --git a/usr.bin/aucat/aucat.c b/usr.bin/aucat/aucat.c
index 6405d8eef29..f315cfeb526 100644
--- a/usr.bin/aucat/aucat.c
+++ b/usr.bin/aucat/aucat.c
@@ -157,14 +157,13 @@ slot_log(struct slot *s)
static void
slot_flush(struct slot *s)
{
- int todo, count, n;
+ int count, n;
unsigned char *data;
- todo = s->buf.used;
- while (todo > 0) {
+ for (;;) {
data = abuf_rgetblk(&s->buf, &count);
- if (count > todo)
- count = todo;
+ if (count == 0)
+ break;
n = afile_write(&s->afile, data, count);
if (n == 0) {
slot_log(s);
@@ -173,21 +172,19 @@ slot_flush(struct slot *s)
return;
}
abuf_rdiscard(&s->buf, n);
- todo -= n;
}
}
static void
slot_fill(struct slot *s)
{
- int todo, count, n;
+ int count, n;
unsigned char *data;
- todo = s->buf.len;
- while (todo > 0) {
+ for (;;) {
data = abuf_wgetblk(&s->buf, &count);
- if (count > todo)
- count = todo;
+ if (count == 0)
+ break;
n = afile_read(&s->afile, data, count);
if (n == 0) {
#ifdef DEBUG
@@ -200,7 +197,6 @@ slot_fill(struct slot *s)
break;
}
abuf_wcommit(&s->buf, n);
- todo -= n;
}
}