Fixed a possibly crashing bug (missing strerror() with %s format).
Fixed many warnings (due to -Wall). Some style cleanups. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2843 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -60,14 +60,14 @@ Journal::CheckLogEntry(int32 count,off_t *array)
|
||||
status_t
|
||||
Journal::ReplayLogEntry(int32 *_start)
|
||||
{
|
||||
PRINT(("ReplayLogEntry(start = %u)\n",*_start));
|
||||
PRINT(("ReplayLogEntry(start = %ld)\n", *_start));
|
||||
|
||||
off_t logOffset = fVolume->ToBlock(fVolume->Log());
|
||||
off_t arrayBlock = (*_start % fLogSize) + fVolume->ToBlock(fVolume->Log());
|
||||
int32 blockSize = fVolume->BlockSize();
|
||||
int32 count = 1, valuesInBlock = blockSize / sizeof(off_t);
|
||||
int32 numArrayBlocks;
|
||||
off_t blockNumber;
|
||||
off_t blockNumber = 0;
|
||||
bool first = true;
|
||||
|
||||
CachedBlock cached(fVolume);
|
||||
@@ -78,10 +78,10 @@ Journal::ReplayLogEntry(int32 *_start)
|
||||
|
||||
int32 index = 0;
|
||||
if (first) {
|
||||
count = array[0];
|
||||
if (count < 1 || count >= fLogSize)
|
||||
if (array[0] < 1 || array[0] >= fLogSize)
|
||||
return B_BAD_DATA;
|
||||
|
||||
count = array[0];
|
||||
first = false;
|
||||
|
||||
numArrayBlocks = ((count + 1) * sizeof(off_t) + blockSize - 1) / blockSize;
|
||||
@@ -105,7 +105,8 @@ Journal::ReplayLogEntry(int32 *_start)
|
||||
if (copy == NULL)
|
||||
RETURN_ERROR(B_IO_ERROR);
|
||||
|
||||
ssize_t written = write_pos(fVolume->Device(),array[index] << fVolume->BlockShift(),copy,blockSize);
|
||||
ssize_t written = write_pos(fVolume->Device(),
|
||||
array[index] << fVolume->BlockShift(), copy, blockSize);
|
||||
if (written != blockSize)
|
||||
RETURN_ERROR(B_IO_ERROR);
|
||||
|
||||
@@ -134,7 +135,6 @@ Journal::ReplayLog()
|
||||
int32 start = fVolume->LogStart();
|
||||
int32 lastStart = -1;
|
||||
while (true) {
|
||||
|
||||
// stop if the log is completely flushed
|
||||
if (start == fVolume->LogEnd())
|
||||
break;
|
||||
@@ -147,7 +147,7 @@ Journal::ReplayLog()
|
||||
|
||||
status_t status = ReplayLogEntry(&start);
|
||||
if (status < B_OK) {
|
||||
FATAL(("replaying log entry from %u failed: %s\n",start,strerror(status)));
|
||||
FATAL(("replaying log entry from %ld failed: %s\n", start, strerror(status)));
|
||||
return B_ERROR;
|
||||
}
|
||||
start = start % fLogSize;
|
||||
@@ -247,7 +247,8 @@ Journal::WriteLogEntry()
|
||||
uint8 *arrayBlock = (uint8 *)array;
|
||||
|
||||
for (int32 size = fArray.BlocksUsed(); size-- > 0;) {
|
||||
write_pos(fVolume->Device(),logOffset + (logPosition << blockShift),arrayBlock,fVolume->BlockSize());
|
||||
write_pos(fVolume->Device(), logOffset + (logPosition << blockShift),
|
||||
arrayBlock, fVolume->BlockSize());
|
||||
|
||||
logPosition = (logPosition + 1) % fLogSize;
|
||||
arrayBlock += fVolume->BlockSize();
|
||||
@@ -261,7 +262,8 @@ Journal::WriteLogEntry()
|
||||
if (block == NULL)
|
||||
return B_IO_ERROR;
|
||||
|
||||
write_pos(fVolume->Device(),logOffset + (logPosition << blockShift),block,fVolume->BlockSize());
|
||||
write_pos(fVolume->Device(), logOffset + (logPosition << blockShift),
|
||||
block, fVolume->BlockSize());
|
||||
logPosition = (logPosition + 1) % fLogSize;
|
||||
}
|
||||
|
||||
@@ -317,7 +319,7 @@ Journal::FlushLogAndBlocks()
|
||||
if (TransactionSize() != 0) {
|
||||
status = WriteLogEntry();
|
||||
if (status < B_OK)
|
||||
FATAL(("writing current log entry failed: %s\n",status));
|
||||
FATAL(("writing current log entry failed: %s\n", strerror(status)));
|
||||
}
|
||||
status = fVolume->FlushDevice();
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class Journal {
|
||||
status_t FlushLogAndBlocks();
|
||||
Volume *GetVolume() const { return fVolume; }
|
||||
|
||||
inline int32 FreeLogBlocks() const;
|
||||
inline uint32 FreeLogBlocks() const;
|
||||
|
||||
private:
|
||||
friend log_entry;
|
||||
@@ -83,7 +83,7 @@ class Journal {
|
||||
};
|
||||
|
||||
|
||||
inline int32
|
||||
inline uint32
|
||||
Journal::FreeLogBlocks() const
|
||||
{
|
||||
return fVolume->LogStart() <= fVolume->LogEnd() ?
|
||||
|
||||
Reference in New Issue
Block a user