[libbluray-devel] Add some casts

Petri Hintukainen git at videolan.org
Sat Jun 24 17:51:50 CEST 2017


libudfread | branch: master | Petri Hintukainen <phintuka at gmail.com> | Sat Jun 24 18:46:38 2017 +0300| [09dcebc2ed7561e71701e707fca39a889032eb96] | committer: Petri Hintukainen

Add some casts

> http://git.videolan.org/gitweb.cgi/libudfread.git/?a=commit;h=09dcebc2ed7561e71701e707fca39a889032eb96
---

 src/default_blockinput.c |  4 ++--
 src/udfread.c            | 14 +++++++-------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/default_blockinput.c b/src/default_blockinput.c
index aaa8c62..fb2ec5f 100644
--- a/src/default_blockinput.c
+++ b/src/default_blockinput.c
@@ -147,7 +147,7 @@ static int _def_read(udfread_block_input *p_gen, uint32_t lba, void *buf, uint32
     pos   = (off_t)lba * UDF_BLOCK_SIZE;
 
     while (got < bytes) {
-        ssize_t ret = pread(p->fd, ((char*)buf) + got, bytes - got, pos + got);
+        ssize_t ret = pread(p->fd, ((char*)buf) + got, bytes - got, pos + (off_t)got);
 
         if (ret <= 0) {
             if (ret < 0 && errno == EINTR) {
@@ -158,7 +158,7 @@ static int _def_read(udfread_block_input *p_gen, uint32_t lba, void *buf, uint32
             }
             break;
         }
-        got += ret;
+        got += (size_t)ret;
     }
 
     return got / UDF_BLOCK_SIZE;
diff --git a/src/udfread.c b/src/udfread.c
index 34cfa34..e2dc9f0 100644
--- a/src/udfread.c
+++ b/src/udfread.c
@@ -249,7 +249,7 @@ static uint32_t _read_blocks(udfread_block_input *input,
 
     result = input->read(input, lba, buf, nblocks, flags);
 
-    return result < 0 ? 0 : result;
+    return result < 0 ? 0 : (uint32_t)result;
 }
 
 static int _read_descriptor_block(udfread_block_input *input, uint32_t lba, uint8_t *buf)
@@ -923,7 +923,7 @@ static int _parse_dir(const uint8_t *data, uint32_t length, struct udf_dir *dir)
             return -1;
         }
 
-        used = decode_file_identifier(p, end - p, &fid);
+        used = decode_file_identifier(p, (size_t)(end - p), &fid);
         if (used == 0) {
             /* not enough data. keep the entries we already have. */
             break;
@@ -1409,7 +1409,7 @@ UDFFILE *udfread_file_open(udfread *udf, const char *path)
 int64_t udfread_file_size(UDFFILE *p)
 {
     if (p) {
-        return p->fe->length;
+        return (int64_t)p->fe->length;
     }
     return -1;
 }
@@ -1562,7 +1562,7 @@ static ssize_t _read(UDFFILE *p, void *buf, size_t bytes)
         }
         memcpy(buf, p->block + pos_off, chunk_size);
         p->pos += (uint64_t)chunk_size;
-        return chunk_size;
+        return (ssize_t)chunk_size;
     }
 
     /* read full block(s) ? */
@@ -1583,7 +1583,7 @@ static ssize_t _read(UDFFILE *p, void *buf, size_t bytes)
     p->block_valid = 1;
     memcpy(buf, p->block, bytes);
     p->pos += bytes;
-    return bytes;
+    return (ssize_t)bytes;
 }
 
 static ssize_t _read_inline(UDFFILE *p, void *buf, size_t bytes)
@@ -1630,7 +1630,7 @@ ssize_t udfread_file_read(UDFFILE *p, void *buf, size_t bytes)
 
     /* limit range to file size */
     if (p->pos + bytes > p->fe->length) {
-        bytes = p->fe->length - p->pos;
+        bytes = (size_t)(p->fe->length - p->pos);
     }
 
     /* small files may be stored inline in file entry */
@@ -1659,7 +1659,7 @@ ssize_t udfread_file_read(UDFFILE *p, void *buf, size_t bytes)
             return -1;
         }
         bufpt += r;
-        bytes -= r;
+        bytes -= (size_t)r;
     }
 
     return (intptr_t)bufpt - (intptr_t)buf;



More information about the libbluray-devel mailing list