Use casts that are more portable.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42177 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2011-06-14 11:27:24 +00:00
parent 32a44923a6
commit e76046d3f9
+10 -10
View File
@@ -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<off_t>(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;
@@ -192,12 +192,12 @@ BMemoryIO::WriteAt(off_t pos, const void *buffer, size_t size)
return B_BAD_VALUE;
ssize_t sizeWritten = 0;
if (pos < fBufferSize) {
sizeWritten = min_c(static_cast<off_t>(size), fBufferSize - pos);
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;
@@ -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<off_t>(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<off_t>(fLength));
size_t newSize = max_c(pos + (off_t)size, (off_t)fLength);
status_t error = B_OK;
if (newSize > fMallocSize)
@@ -361,7 +361,7 @@ 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<char*>(realloc(fData, newSize))) {
// set the new area to 0