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:
Axel Dörfler
2003-02-25 03:03:30 +00:00
parent 4c94430a7e
commit ceeb00d41a
2 changed files with 35 additions and 33 deletions
+12 -10
View File
@@ -60,14 +60,14 @@ Journal::CheckLogEntry(int32 count,off_t *array)
status_t status_t
Journal::ReplayLogEntry(int32 *_start) 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 logOffset = fVolume->ToBlock(fVolume->Log());
off_t arrayBlock = (*_start % fLogSize) + fVolume->ToBlock(fVolume->Log()); off_t arrayBlock = (*_start % fLogSize) + fVolume->ToBlock(fVolume->Log());
int32 blockSize = fVolume->BlockSize(); int32 blockSize = fVolume->BlockSize();
int32 count = 1, valuesInBlock = blockSize / sizeof(off_t); int32 count = 1, valuesInBlock = blockSize / sizeof(off_t);
int32 numArrayBlocks; int32 numArrayBlocks;
off_t blockNumber; off_t blockNumber = 0;
bool first = true; bool first = true;
CachedBlock cached(fVolume); CachedBlock cached(fVolume);
@@ -78,10 +78,10 @@ Journal::ReplayLogEntry(int32 *_start)
int32 index = 0; int32 index = 0;
if (first) { if (first) {
count = array[0]; if (array[0] < 1 || array[0] >= fLogSize)
if (count < 1 || count >= fLogSize)
return B_BAD_DATA; return B_BAD_DATA;
count = array[0];
first = false; first = false;
numArrayBlocks = ((count + 1) * sizeof(off_t) + blockSize - 1) / blockSize; numArrayBlocks = ((count + 1) * sizeof(off_t) + blockSize - 1) / blockSize;
@@ -105,7 +105,8 @@ Journal::ReplayLogEntry(int32 *_start)
if (copy == NULL) if (copy == NULL)
RETURN_ERROR(B_IO_ERROR); 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) if (written != blockSize)
RETURN_ERROR(B_IO_ERROR); RETURN_ERROR(B_IO_ERROR);
@@ -134,7 +135,6 @@ Journal::ReplayLog()
int32 start = fVolume->LogStart(); int32 start = fVolume->LogStart();
int32 lastStart = -1; int32 lastStart = -1;
while (true) { while (true) {
// stop if the log is completely flushed // stop if the log is completely flushed
if (start == fVolume->LogEnd()) if (start == fVolume->LogEnd())
break; break;
@@ -147,7 +147,7 @@ Journal::ReplayLog()
status_t status = ReplayLogEntry(&start); status_t status = ReplayLogEntry(&start);
if (status < B_OK) { 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; return B_ERROR;
} }
start = start % fLogSize; start = start % fLogSize;
@@ -247,7 +247,8 @@ Journal::WriteLogEntry()
uint8 *arrayBlock = (uint8 *)array; uint8 *arrayBlock = (uint8 *)array;
for (int32 size = fArray.BlocksUsed(); size-- > 0;) { 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; logPosition = (logPosition + 1) % fLogSize;
arrayBlock += fVolume->BlockSize(); arrayBlock += fVolume->BlockSize();
@@ -261,7 +262,8 @@ Journal::WriteLogEntry()
if (block == NULL) if (block == NULL)
return B_IO_ERROR; 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; logPosition = (logPosition + 1) % fLogSize;
} }
@@ -317,7 +319,7 @@ Journal::FlushLogAndBlocks()
if (TransactionSize() != 0) { if (TransactionSize() != 0) {
status = WriteLogEntry(); status = WriteLogEntry();
if (status < B_OK) 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(); status = fVolume->FlushDevice();
@@ -60,7 +60,7 @@ class Journal {
status_t FlushLogAndBlocks(); status_t FlushLogAndBlocks();
Volume *GetVolume() const { return fVolume; } Volume *GetVolume() const { return fVolume; }
inline int32 FreeLogBlocks() const; inline uint32 FreeLogBlocks() const;
private: private:
friend log_entry; friend log_entry;
@@ -83,7 +83,7 @@ class Journal {
}; };
inline int32 inline uint32
Journal::FreeLogBlocks() const Journal::FreeLogBlocks() const
{ {
return fVolume->LogStart() <= fVolume->LogEnd() ? return fVolume->LogStart() <= fVolume->LogEnd() ?