]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - ogg_afh.c
Replace MAX, MIN, ABS macros by type-checking variants.
[paraslash.git] / ogg_afh.c
index 11f7f5ad53a9a1f999fa7c7076d88df3aeb4407b..b6132edf7bc3740c55836df48d62d66c9ee5609e 100644 (file)
--- a/ogg_afh.c
+++ b/ogg_afh.c
@@ -34,8 +34,15 @@ struct ogg_datasource {
 static size_t cb_read(void *buf, size_t size, size_t nmemb, void *datasource)
 {
        struct ogg_datasource *ods = datasource;
-       size_t copy = PARA_MIN(ods->numbytes - ods->fpos, size * nmemb),
-               ret = copy / size;
+       size_t copy, ret;
+
+       if (!size)
+               return 0;
+
+       assert(ods->numbytes >= ods->fpos);
+       ret = ods->numbytes - ods->fpos;
+       copy = PARA_MIN(ret, size * nmemb);
+       ret = copy / size;
        if (!ret)
                return 0;
        memcpy(buf, ods->map + ods->fpos, copy);
@@ -115,7 +122,7 @@ static int ogg_compute_header_len(char *map, size_t numbytes,
                struct afh_info *afhi)
 {
        int ret;
-       size_t len = PARA_MIN(numbytes, CHUNK_SIZE);
+       size_t len = PARA_MIN(numbytes, (size_t)CHUNK_SIZE);
        int serial;
        char *buf;