Added a missing check of the return value of a cached write in

Inode::FillGapWithZeros(), pointed out by Mike Nordell.
Note, that function is currently not used.
Some smaller cleanups.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1058 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2002-09-16 15:13:23 +00:00
parent 502d10e3ff
commit fb34ad79d7
+11 -9
View File
@@ -907,14 +907,15 @@ Inode::WriteAt(Transaction *transaction,off_t pos,const uint8 *buffer,size_t *_l
*/ */
status_t status_t
Inode::FillGapWithZeros(off_t pos,off_t newSize) Inode::FillGapWithZeros(off_t pos, off_t newSize)
{ {
// ToDo: we currently do anything here, same as original BFS!
//if (pos >= newSize) //if (pos >= newSize)
return B_OK; return B_OK;
block_run run; block_run run;
off_t offset; off_t offset;
if (FindBlockRun(pos,run,offset) < B_OK) if (FindBlockRun(pos, run, offset) < B_OK)
RETURN_ERROR(B_BAD_VALUE); RETURN_ERROR(B_BAD_VALUE);
off_t length = newSize - pos; off_t length = newSize - pos;
@@ -939,8 +940,9 @@ Inode::FillGapWithZeros(off_t pos,off_t newSize)
if (length < bytesWritten) if (length < bytesWritten)
bytesWritten = length; bytesWritten = length;
memset(block + (pos % blockSize),0,bytesWritten); memset(block + (pos % blockSize), 0, bytesWritten);
fVolume->WriteBlocks(cached.BlockNumber(),block,1); if (fVolume->WriteBlocks(cached.BlockNumber(), block, 1) < B_OK)
RETURN_ERROR(B_IO_ERROR);
pos += bytesWritten; pos += bytesWritten;
@@ -948,7 +950,7 @@ Inode::FillGapWithZeros(off_t pos,off_t newSize)
if (length == 0) if (length == 0)
return B_OK; return B_OK;
if (FindBlockRun(pos,run,offset) < B_OK) if (FindBlockRun(pos, run, offset) < B_OK)
RETURN_ERROR(B_BAD_VALUE); RETURN_ERROR(B_BAD_VALUE);
} }
@@ -959,11 +961,11 @@ Inode::FillGapWithZeros(off_t pos,off_t newSize)
CachedBlock cached(fVolume); CachedBlock cached(fVolume);
off_t blockNumber = fVolume->ToBlock(run); off_t blockNumber = fVolume->ToBlock(run);
for (int32 i = 0;i < run.length;i++) { for (int32 i = 0; i < run.length; i++) {
if ((block = cached.SetTo(blockNumber + i,true)) == NULL) if ((block = cached.SetTo(blockNumber + i, true)) == NULL)
RETURN_ERROR(B_IO_ERROR); RETURN_ERROR(B_IO_ERROR);
if (fVolume->WriteBlocks(cached.BlockNumber(),block,1) < B_OK) if (fVolume->WriteBlocks(cached.BlockNumber(), block, 1) < B_OK)
RETURN_ERROR(B_IO_ERROR); RETURN_ERROR(B_IO_ERROR);
} }
@@ -977,7 +979,7 @@ Inode::FillGapWithZeros(off_t pos,off_t newSize)
pos += bytes; pos += bytes;
if (FindBlockRun(pos,run,offset) < B_OK) if (FindBlockRun(pos, run, offset) < B_OK)
RETURN_ERROR(B_BAD_VALUE); RETURN_ERROR(B_BAD_VALUE);
} }
return B_OK; return B_OK;