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:
parent
32a44923a6
commit
e76046d3f9
@ -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;
|
||||
@ -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<off_t>(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<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,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<char*>(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
|
||||
|
Loading…
Reference in New Issue
Block a user