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:
+10
-10
@@ -174,8 +174,8 @@ BMemoryIO::ReadAt(off_t pos, void *buffer, size_t size)
|
|||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
ssize_t sizeRead = 0;
|
ssize_t sizeRead = 0;
|
||||||
if (pos < fLength) {
|
if (pos < (off_t)fLength) {
|
||||||
sizeRead = min_c(static_cast<off_t>(size), fLength - pos);
|
sizeRead = min_c((off_t)size, (off_t)fLength - pos);
|
||||||
memcpy(buffer, fBuffer + pos, sizeRead);
|
memcpy(buffer, fBuffer + pos, sizeRead);
|
||||||
}
|
}
|
||||||
return sizeRead;
|
return sizeRead;
|
||||||
@@ -192,12 +192,12 @@ BMemoryIO::WriteAt(off_t pos, const void *buffer, size_t size)
|
|||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
ssize_t sizeWritten = 0;
|
ssize_t sizeWritten = 0;
|
||||||
if (pos < fBufferSize) {
|
if (pos < (off_t)fBufferSize) {
|
||||||
sizeWritten = min_c(static_cast<off_t>(size), fBufferSize - pos);
|
sizeWritten = min_c((off_t)size, (off_t)fBufferSize - pos);
|
||||||
memcpy(fBuffer + pos, buffer, sizeWritten);
|
memcpy(fBuffer + pos, buffer, sizeWritten);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pos + sizeWritten > fLength)
|
if (pos + sizeWritten > (off_t)fLength)
|
||||||
fLength = pos + sizeWritten;
|
fLength = pos + sizeWritten;
|
||||||
|
|
||||||
return sizeWritten;
|
return sizeWritten;
|
||||||
@@ -237,7 +237,7 @@ BMemoryIO::SetSize(off_t size)
|
|||||||
if (fReadOnly)
|
if (fReadOnly)
|
||||||
return B_NOT_ALLOWED;
|
return B_NOT_ALLOWED;
|
||||||
|
|
||||||
if (size > fBufferSize)
|
if (size > (off_t)fBufferSize)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
fLength = size;
|
fLength = size;
|
||||||
@@ -293,8 +293,8 @@ BMallocIO::ReadAt(off_t pos, void *buffer, size_t size)
|
|||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
|
|
||||||
ssize_t sizeRead = 0;
|
ssize_t sizeRead = 0;
|
||||||
if (pos < fLength) {
|
if (pos < (off_t)fLength) {
|
||||||
sizeRead = min_c(static_cast<off_t>(size), fLength - pos);
|
sizeRead = min_c((off_t)size, (off_t)fLength - pos);
|
||||||
memcpy(buffer, fData + pos, sizeRead);
|
memcpy(buffer, fData + pos, sizeRead);
|
||||||
}
|
}
|
||||||
return sizeRead;
|
return sizeRead;
|
||||||
@@ -307,7 +307,7 @@ BMallocIO::WriteAt(off_t pos, const void *buffer, size_t size)
|
|||||||
if (buffer == NULL)
|
if (buffer == NULL)
|
||||||
return B_BAD_VALUE;
|
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;
|
status_t error = B_OK;
|
||||||
|
|
||||||
if (newSize > fMallocSize)
|
if (newSize > fMallocSize)
|
||||||
@@ -361,7 +361,7 @@ BMallocIO::SetSize(off_t size)
|
|||||||
} else {
|
} else {
|
||||||
// size != 0, see, if necessary to resize
|
// size != 0, see, if necessary to resize
|
||||||
size_t newSize = (size + fBlockSize - 1) / fBlockSize * fBlockSize;
|
size_t newSize = (size + fBlockSize - 1) / fBlockSize * fBlockSize;
|
||||||
if (size != fMallocSize) {
|
if (size != (off_t)fMallocSize) {
|
||||||
// we need to resize
|
// we need to resize
|
||||||
if (char *newData = static_cast<char*>(realloc(fData, newSize))) {
|
if (char *newData = static_cast<char*>(realloc(fData, newSize))) {
|
||||||
// set the new area to 0
|
// set the new area to 0
|
||||||
|
|||||||
Reference in New Issue
Block a user