]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
mp4: Clean up membuffer_transfer_from_file().
authorAndre Noll <maan@tuebingen.mpg.de>
Sat, 14 Aug 2021 21:14:38 +0000 (23:14 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Mon, 30 May 2022 19:37:35 +0000 (21:37 +0200)
The buffer pointer can never be NULL, so drop this check. Next, instead
of defining a void * pointer and cast it to char *, use char * directly.
Finally, the cast to unsigned has no effect, so drop it.

mp4.c

diff --git a/mp4.c b/mp4.c
index c0efc4fa77d53013e8445fb9b261ea3e9677ac9b..e20cf9385bf1a9138a342945e6e1d42bf8eabe91 100644 (file)
--- a/mp4.c
+++ b/mp4.c
@@ -1275,17 +1275,12 @@ static void *membuffer_get_ptr(const struct membuffer *buf)
 static bool membuffer_transfer_from_file(struct membuffer *buf, struct mp4 *src,
                unsigned bytes)
 {
-       unsigned oldsize;
-       void *bufptr;
+       unsigned oldsize = membuffer_get_size(buf);
+       char *bufptr;
 
-       oldsize = membuffer_get_size(buf);
        membuffer_write(buf, 0, bytes);
        bufptr = membuffer_get_ptr(buf);
-       if (bufptr == 0)
-               return false;
-
-       if ((unsigned)read_data(src, (char *) bufptr + oldsize, bytes) !=
-               bytes) {
+       if (read_data(src, bufptr + oldsize, bytes) != bytes) {
                membuffer_free(buf);
                return false;
        }