From e76046d3f9ffeec1a155f314b61d91e7362a63cb Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Tue, 14 Jun 2011 11:27:24 +0000 Subject: [PATCH] Use casts that are more portable. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42177 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/support/DataIO.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/kits/support/DataIO.cpp b/src/kits/support/DataIO.cpp index 753551adab..aee5f212ae 100644 --- a/src/kits/support/DataIO.cpp +++ b/src/kits/support/DataIO.cpp @@ -174,8 +174,8 @@ BMemoryIO::ReadAt(off_t pos, void *buffer, size_t size) return B_BAD_VALUE; ssize_t sizeRead = 0; - if (pos < fLength) { - sizeRead = min_c(static_cast(size), fLength - pos); + if (pos < (off_t)fLength) { + sizeRead = min_c((off_t)size, (off_t)fLength - pos); memcpy(buffer, fBuffer + pos, sizeRead); } return sizeRead; @@ -184,20 +184,20 @@ BMemoryIO::ReadAt(off_t pos, void *buffer, size_t size) ssize_t BMemoryIO::WriteAt(off_t pos, const void *buffer, size_t size) -{ +{ if (fReadOnly) return B_NOT_ALLOWED; if (buffer == NULL || pos < 0) return B_BAD_VALUE; - ssize_t sizeWritten = 0; - if (pos < fBufferSize) { - sizeWritten = min_c(static_cast(size), fBufferSize - pos); + ssize_t sizeWritten = 0; + if (pos < (off_t)fBufferSize) { + sizeWritten = min_c((off_t)size, (off_t)fBufferSize - pos); memcpy(fBuffer + pos, buffer, sizeWritten); } - if (pos + sizeWritten > fLength) + if (pos + sizeWritten > (off_t)fLength) fLength = pos + sizeWritten; return sizeWritten; @@ -213,13 +213,13 @@ BMemoryIO::Seek(off_t position, uint32 seek_mode) break; case SEEK_CUR: fPosition += position; - break; + break; case SEEK_END: fPosition = fLength + position; break; default: break; - } + } return fPosition; } @@ -237,7 +237,7 @@ BMemoryIO::SetSize(off_t size) if (fReadOnly) return B_NOT_ALLOWED; - if (size > fBufferSize) + if (size > (off_t)fBufferSize) return B_ERROR; fLength = size; @@ -293,8 +293,8 @@ BMallocIO::ReadAt(off_t pos, void *buffer, size_t size) return B_BAD_VALUE; ssize_t sizeRead = 0; - if (pos < fLength) { - sizeRead = min_c(static_cast(size), fLength - pos); + if (pos < (off_t)fLength) { + sizeRead = min_c((off_t)size, (off_t)fLength - pos); memcpy(buffer, fData + pos, sizeRead); } return sizeRead; @@ -307,7 +307,7 @@ BMallocIO::WriteAt(off_t pos, const void *buffer, size_t size) if (buffer == NULL) return B_BAD_VALUE; - size_t newSize = max_c(pos + size, static_cast(fLength)); + size_t newSize = max_c(pos + (off_t)size, (off_t)fLength); status_t error = B_OK; if (newSize > fMallocSize) @@ -361,12 +361,12 @@ BMallocIO::SetSize(off_t size) } else { // size != 0, see, if necessary to resize size_t newSize = (size + fBlockSize - 1) / fBlockSize * fBlockSize; - if (size != fMallocSize) { + if (size != (off_t)fMallocSize) { // we need to resize if (char *newData = static_cast(realloc(fData, newSize))) { // set the new area to 0 if (newSize > fMallocSize) - memset(newData + fMallocSize, 0, newSize - fMallocSize); + memset(newData + fMallocSize, 0, newSize - fMallocSize); fData = newData; fMallocSize = newSize; } else // couldn't alloc the memory