]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
aac_afh: Be more lenient about zero sized reads.
authorAndre Noll <maan@tuebingen.mpg.de>
Wed, 18 Aug 2021 14:44:15 +0000 (16:44 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sat, 12 Mar 2022 17:35:17 +0000 (18:35 +0100)
These actually happen for example when the file contains a meta
tag with an empty string value. POSIX says that the read() function
shall return zero and have no other results, so don't return -1 if
the number of bytes read is zero.

Similarly, return zero if the file offset is beyond EOF.

aac_afh.c

index 2b3dd2cc538a57a233813b77adcb332bd77929ce..026df50f00c43bff16294d3ec26a869517f7e3c1 100644 (file)
--- a/aac_afh.c
+++ b/aac_afh.c
@@ -37,12 +37,8 @@ static uint32_t aac_afh_read_cb(void *user_data, void *dest, uint32_t want)
        struct aac_afh_context *c = user_data;
        uint32_t have, rv;
 
-       if (want == 0 || c->fpos >= c->mapsize) {
-               PARA_INFO_LOG("failed attempt to read %u bytes @%zu\n", want,
-                       c->fpos);
-               errno = EAGAIN;
-               return -1;
-       }
+       if (want == 0 || c->fpos >= c->mapsize)
+               return 0;
        have = c->mapsize - c->fpos;
        rv = PARA_MIN(have, want);
        PARA_DEBUG_LOG("reading %u bytes @%zu\n", rv, c->fpos);