ramfs: Fix debugging print macro invocations and use B_PRI*.

This commit is contained in:
Augustin Cavalier
2019-08-30 20:53:15 -04:00
parent b2c20927e8
commit 2914364270
11 changed files with 125 additions and 125 deletions
@@ -172,68 +172,68 @@ AllocationInfo::Dump() const
size_t areaCount = 0; size_t areaCount = 0;
size_t areaSize = 0; size_t areaSize = 0;
PRINT((" node table:\n")); PRINT(" node table:\n");
PRINT((" array size: %9lu\n", fNodeTableArraySize)); PRINT(" array size: %9lu\n", fNodeTableArraySize);
PRINT((" vector size: %9lu\n", fNodeTableVectorSize)); PRINT(" vector size: %9lu\n", fNodeTableVectorSize);
PRINT((" elements: %9lu\n", fNodeTableElementCount)); PRINT(" elements: %9lu\n", fNodeTableElementCount);
areaCount += 2; areaCount += 2;
areaSize += fNodeTableArraySize * sizeof(int32) + fNodeTableVectorSize; areaSize += fNodeTableArraySize * sizeof(int32) + fNodeTableVectorSize;
PRINT((" entry table:\n")); PRINT(" entry table:\n");
PRINT((" array size: %9lu\n", fDirectoryEntryTableArraySize)); PRINT(" array size: %9lu\n", fDirectoryEntryTableArraySize);
PRINT((" vector size: %9lu\n", fDirectoryEntryTableVectorSize)); PRINT(" vector size: %9lu\n", fDirectoryEntryTableVectorSize);
PRINT((" elements: %9lu\n", fDirectoryEntryTableElementCount)); PRINT(" elements: %9lu\n", fDirectoryEntryTableElementCount);
areaCount += 2; areaCount += 2;
areaSize += fDirectoryEntryTableArraySize * sizeof(int32) areaSize += fDirectoryEntryTableArraySize * sizeof(int32)
+ fDirectoryEntryTableVectorSize; + fDirectoryEntryTableVectorSize;
PRINT((" attribute table:\n")); PRINT(" attribute table:\n");
PRINT((" array size: %9lu\n", fNodeAttributeTableArraySize)); PRINT(" array size: %9lu\n", fNodeAttributeTableArraySize);
PRINT((" vector size: %9lu\n", fNodeAttributeTableVectorSize)); PRINT(" vector size: %9lu\n", fNodeAttributeTableVectorSize);
PRINT((" elements: %9lu\n", fNodeAttributeTableElementCount)); PRINT(" elements: %9lu\n", fNodeAttributeTableElementCount);
areaCount += 2; areaCount += 2;
areaSize += fNodeAttributeTableArraySize * sizeof(int32) areaSize += fNodeAttributeTableArraySize * sizeof(int32)
+ fNodeAttributeTableVectorSize; + fNodeAttributeTableVectorSize;
PRINT((" attributes: %9lu, size: %9lu\n", fAttributeCount, fAttributeSize)); PRINT(" attributes: %9lu, size: %9lu\n", fAttributeCount, fAttributeSize);
heapCount += fAttributeCount; heapCount += fAttributeCount;
heapSize += fAttributeCount * sizeof(Attribute); heapSize += fAttributeCount * sizeof(Attribute);
PRINT((" directories: %9lu\n", fDirectoryCount)); PRINT(" directories: %9lu\n", fDirectoryCount);
heapCount += fDirectoryCount; heapCount += fDirectoryCount;
heapSize += fDirectoryCount * sizeof(Directory); heapSize += fDirectoryCount * sizeof(Directory);
PRINT((" entries: %9lu\n", fEntryCount)); PRINT(" entries: %9lu\n", fEntryCount);
heapCount += fEntryCount; heapCount += fEntryCount;
heapSize += fEntryCount * sizeof(Entry); heapSize += fEntryCount * sizeof(Entry);
PRINT((" files: %9lu, size: %9lu\n", fFileCount, fFileSize)); PRINT(" files: %9lu, size: %9lu\n", fFileCount, fFileSize);
heapCount += fFileCount; heapCount += fFileCount;
heapSize += fFileCount * sizeof(File); heapSize += fFileCount * sizeof(File);
PRINT((" symlinks: %9lu, size: %9lu\n", fSymLinkCount, fSymLinkSize)); PRINT(" symlinks: %9lu, size: %9lu\n", fSymLinkCount, fSymLinkSize);
heapCount += fSymLinkCount; heapCount += fSymLinkCount;
heapSize += fSymLinkCount * sizeof(SymLink); heapSize += fSymLinkCount * sizeof(SymLink);
PRINT((" areas: %9lu, size: %9lu\n", fAreaCount, fAreaSize)); PRINT(" areas: %9lu, size: %9lu\n", fAreaCount, fAreaSize);
areaCount += fAreaCount; areaCount += fAreaCount;
areaSize += fAreaSize; areaSize += fAreaSize;
PRINT((" blocks: %9lu, size: %9lu\n", fBlockCount, fBlockSize)); PRINT(" blocks: %9lu, size: %9lu\n", fBlockCount, fBlockSize);
PRINT((" lists: %9lu, size: %9lu\n", fListCount, fListSize)); PRINT(" lists: %9lu, size: %9lu\n", fListCount, fListSize);
heapCount += fListCount; heapCount += fListCount;
heapSize += fListSize; heapSize += fListSize;
PRINT((" other: %9lu, size: %9lu\n", fOtherCount, fOtherSize)); PRINT(" other: %9lu, size: %9lu\n", fOtherCount, fOtherSize);
heapCount += fOtherCount; heapCount += fOtherCount;
heapSize += fOtherSize; heapSize += fOtherSize;
PRINT((" strings: %9lu, size: %9lu\n", fStringCount, fStringSize)); PRINT(" strings: %9lu, size: %9lu\n", fStringCount, fStringSize);
heapCount += fStringCount; heapCount += fStringCount;
heapSize += fStringSize; heapSize += fStringSize;
PRINT(("heap: %9lu allocations, size: %9lu\n", heapCount, heapSize)); PRINT("heap: %9lu allocations, size: %9lu\n", heapCount, heapSize);
PRINT(("areas: %9lu allocations, size: %9lu\n", areaCount, areaSize)); PRINT("areas: %9lu allocations, size: %9lu\n", areaCount, areaSize);
} }
@@ -274,7 +274,7 @@ AttributeIndexImpl::Changed(Attribute *attribute, const uint8 *oldKey,
status_t status_t
AttributeIndexImpl::Added(Attribute *attribute) AttributeIndexImpl::Added(Attribute *attribute)
{ {
PRINT(("AttributeIndex::Add(%p)\n", attribute)); PRINT("AttributeIndex::Add(%p)\n", attribute);
status_t error = (attribute ? B_OK : B_BAD_VALUE); status_t error = (attribute ? B_OK : B_BAD_VALUE);
if (error == B_OK) { if (error == B_OK) {
size_t size = attribute->GetSize(); size_t size = attribute->GetSize();
@@ -293,7 +293,7 @@ PRINT(("AttributeIndex::Add(%p)\n", attribute));
bool bool
AttributeIndexImpl::Removed(Attribute *attribute) AttributeIndexImpl::Removed(Attribute *attribute)
{ {
PRINT(("AttributeIndex::Removed(%p)\n", attribute)); PRINT("AttributeIndex::Removed(%p)\n", attribute);
bool result = (attribute && attribute->GetIndex() == this); bool result = (attribute && attribute->GetIndex() == this);
if (result) { if (result) {
if (attribute->IsInIndex()) if (attribute->IsInIndex())
@@ -381,13 +381,13 @@ AttributeIndexImpl::Iterator::GetCurrent(uint8 *buffer, size_t *keyLength)
(*attribute)->GetKey(buffer, keyLength); (*attribute)->GetKey(buffer, keyLength);
} else { } else {
FATAL("Node of current attribute and node of current entry " FATAL("Node of current attribute and node of current entry "
"differ: %Ld vs. %Ld\n", "differ: %" B_PRIdINO " vs. %" B_PRIdINO "\n",
(*attribute)->GetNode()->GetID(), (*attribute)->GetNode()->GetID(),
entry->GetNode()->GetID()); entry->GetNode()->GetID());
entry = NULL; entry = NULL;
} }
} else { } else {
FATAL("We have a current entry (`%s', node: %Ld), but no current " FATAL("We have a current entry (`%s', node: %" B_PRIdINO "), but no current "
"attribute.\n", entry->GetName(), "attribute.\n", entry->GetName(),
entry->GetNode()->GetID()); entry->GetNode()->GetID());
entry = NULL; entry = NULL;
@@ -178,7 +178,7 @@ BlockAllocator::SanityCheck(bool deep) const
} }
// area count // area count
if (areaCount != fAreaCount) { if (areaCount != fAreaCount) {
FATAL("fAreaCount is %ld, but should be %ld\n", fAreaCount, FATAL("fAreaCount is %" B_PRId32 ", but should be %" B_PRId32 "\n", fAreaCount,
areaCount); areaCount);
BA_PANIC("BlockAllocator: Bad free bytes."); BA_PANIC("BlockAllocator: Bad free bytes.");
return false; return false;
@@ -279,8 +279,8 @@ BlockAllocator::_AllocateBlock(size_t usableSize, bool dontCreateArea)
fFreeBytes += area->GetFreeBytes(); fFreeBytes += area->GetFreeBytes();
bucket = fBuckets + area->GetBucketIndex(); bucket = fBuckets + area->GetBucketIndex();
bucket->AddArea(area); bucket->AddArea(area);
PRINT(("New area allocated. area count now: %ld, free bytes: %lu\n", PRINT("New area allocated. area count now: %" B_PRId32 ", free bytes: %lu\n",
fAreaCount, fFreeBytes)); fAreaCount, fFreeBytes);
} }
} }
// allocate a block // allocate a block
@@ -295,8 +295,8 @@ fAreaCount, fFreeBytes));
} }
#if ENABLE_BA_PANIC #if ENABLE_BA_PANIC
else if (!fPanic) { else if (!fPanic) {
FATAL(("Block allocation failed unexpectedly.\n")); FATAL("Block allocation failed unexpectedly.\n");
PRINT((" usableSize: %lu, areaFreeBytes: %lu\n", usableSize, areaFreeBytes)); PRINT(" usableSize: %lu, areaFreeBytes: %lu\n", usableSize, areaFreeBytes);
BA_PANIC("Block allocation failed unexpectedly."); BA_PANIC("Block allocation failed unexpectedly.");
//block = area->AllocateBlock(usableSize); //block = area->AllocateBlock(usableSize);
} }
@@ -395,8 +395,8 @@ BlockAllocator::_Defragment()
area->FreeBlock(block, true); area->FreeBlock(block, true);
#if ENABLE_BA_PANIC #if ENABLE_BA_PANIC
if (fPanic) { if (fPanic) {
PRINT(("Panicked while trying to free block %p\n", PRINT("Panicked while trying to free block %p\n",
block)); block);
success = false; success = false;
break; break;
} }
@@ -410,9 +410,9 @@ BlockAllocator::_Defragment()
if (success && area->IsEmpty()) { if (success && area->IsEmpty()) {
area->Delete(); area->Delete();
fAreaCount--; fAreaCount--;
PRINT(("defragmenting: area deleted\n")); PRINT("defragmenting: area deleted\n");
} else { } else {
PRINT(("defragmenting: failed to empty area\n")); PRINT("defragmenting: failed to empty area\n");
// failed: re-add the area // failed: re-add the area
fFreeBytes += area->GetFreeBytes(); fFreeBytes += area->GetFreeBytes();
AreaBucket *newBucket = fBuckets + area->GetBucketIndex(); AreaBucket *newBucket = fBuckets + area->GetBucketIndex();
@@ -43,8 +43,8 @@ BlockAllocator::Area::Create(size_t size)
if (id >= 0) { if (id >= 0) {
area = new(base) Area(id, size); area = new(base) Area(id, size);
} else { } else {
ERROR(("BlockAllocator::Area::Create(%lu): Failed to create area: %s\n", ERROR("BlockAllocator::Area::Create(%lu): Failed to create area: %s\n",
size, strerror(id))); size, strerror(id));
} }
return area; return area;
} }
@@ -250,7 +250,7 @@ BlockAllocator::Area::SanityCheck() const
{ {
// area ID // area ID
if (fID < 0) { if (fID < 0) {
FATAL("Area ID < 0: %lx\n", fID); FATAL("Area ID < 0: %" B_PRIx32 "\n", fID);
BA_PANIC("Bad area ID."); BA_PANIC("Bad area ID.");
return false; return false;
} }
@@ -271,7 +271,7 @@ BlockAllocator::Area::SanityCheck() const
} }
// block count // block count
if (fFreeBlockCount + fUsedBlockCount == 0) { if (fFreeBlockCount + fUsedBlockCount == 0) {
FATAL(("Area contains no blocks at all.\n")); FATAL("Area contains no blocks at all.\n");
BA_PANIC("Bad area block count."); BA_PANIC("Bad area block count.");
return false; return false;
} }
@@ -295,8 +295,8 @@ BlockAllocator::Area::SanityCheck() const
for (int32 i = 0; i < blockCount; i++) { for (int32 i = 0; i < blockCount; i++) {
blockListOK = false; blockListOK = false;
if (!block) { if (!block) {
FATAL("Encountered NULL in block list at index %ld, although " FATAL("Encountered NULL in block list at index %" B_PRId32 ", although "
"list should have %ld blocks\n", i, blockCount); "list should have %" B_PRId32 " blocks\n", i, blockCount);
BA_PANIC("Bad area block list."); BA_PANIC("Bad area block list.");
return false; return false;
} }
@@ -321,14 +321,14 @@ BlockAllocator::Area::SanityCheck() const
// alignment // alignment
if (block_align_floor(address) != address if (block_align_floor(address) != address
|| block_align_floor(blockSize) != blockSize) { || block_align_floor(blockSize) != blockSize) {
FATAL("Block %ld not properly aligned: %p, size: %lu\n", FATAL("Block %" B_PRId32 " not properly aligned: %p, size: %lu\n",
i, block, blockSize); i, block, blockSize);
BA_PANIC("Bad area block."); BA_PANIC("Bad area block.");
return false; return false;
} }
// previous block // previous block
if (block->GetPreviousBlock() != prevBlock) { if (block->GetPreviousBlock() != prevBlock) {
FATAL("Previous block of block %ld was not the previous " FATAL("Previous block of block %" B_PRId32 " was not the previous "
"block in list: %p vs %p\n", i, "block in list: %p vs %p\n", i,
block->GetPreviousBlock(), prevBlock); block->GetPreviousBlock(), prevBlock);
BA_PANIC("Bad area block list."); BA_PANIC("Bad area block list.");
@@ -344,14 +344,14 @@ BlockAllocator::Area::SanityCheck() const
freeBytes += freeBlock->GetUsableSize(); freeBytes += freeBlock->GetUsableSize();
// block == next free block of previous free block // block == next free block of previous free block
if (freeBlock != nextFree) { if (freeBlock != nextFree) {
FATAL("Free block %ld is not the next block in free " FATAL("Free block %" B_PRId32 " is not the next block in free "
"list: %p vs %p\n", i, freeBlock, nextFree); "list: %p vs %p\n", i, freeBlock, nextFree);
BA_PANIC("Bad area free list."); BA_PANIC("Bad area free list.");
return false; return false;
} }
// previous free block // previous free block
if (freeBlock->GetPreviousFreeBlock() != prevFree) { if (freeBlock->GetPreviousFreeBlock() != prevFree) {
FATAL("Previous free block of block %ld was not the " FATAL("Previous free block of block %" B_PRId32 " was not the "
" previous block in free list: %p vs %p\n", i, " previous block in free list: %p vs %p\n", i,
freeBlock->GetPreviousFreeBlock(), prevFree); freeBlock->GetPreviousFreeBlock(), prevFree);
BA_PANIC("Bad area free list."); BA_PANIC("Bad area free list.");
@@ -384,13 +384,13 @@ BlockAllocator::Area::SanityCheck() const
} }
// block counts (a bit reduntant) // block counts (a bit reduntant)
if (freeBlockCount != fFreeBlockCount) { if (freeBlockCount != fFreeBlockCount) {
FATAL("Free block count is %ld, but should be %ld\n", FATAL("Free block count is %" B_PRIuSIZE ", but should be %" B_PRIu32 "\n",
fFreeBlockCount, freeBlockCount); fFreeBlockCount, freeBlockCount);
BA_PANIC("Bad area free block count."); BA_PANIC("Bad area free block count.");
return false; return false;
} }
if (usedBlockCount != fUsedBlockCount) { if (usedBlockCount != fUsedBlockCount) {
FATAL("Used block count is %ld, but should be %ld\n", FATAL("Used block count is %" B_PRIuSIZE ", but should be %" B_PRIu32 "\n",
fUsedBlockCount, usedBlockCount); fUsedBlockCount, usedBlockCount);
BA_PANIC("Bad area used block count."); BA_PANIC("Bad area used block count.");
return false; return false;
@@ -74,15 +74,15 @@ D(
if (!blockData) { if (!blockData) {
Node *node = NULL; Node *node = NULL;
if (Attribute *attribute = dynamic_cast<Attribute*>(this)) { if (Attribute *attribute = dynamic_cast<Attribute*>(this)) {
FATAL(("attribute `%s' of\n", attribute->GetName())); FATAL("attribute `%s' of\n", attribute->GetName());
node = attribute->GetNode(); node = attribute->GetNode();
} else { } else {
node = dynamic_cast<Node*>(this); node = dynamic_cast<Node*>(this);
} }
if (node) if (node)
// FATAL(("node `%s'\n", node->GetName())); // FATAL(("node `%s'\n", node->GetName()));
FATAL(("container size: %Ld, offset: %Ld, buffer size: %lu\n", FATAL("container size: %Ld, offset: %Ld, buffer size: %lu\n",
fSize, offset, size)); fSize, offset, size);
return B_ERROR; return B_ERROR;
} }
); );
@@ -308,7 +308,7 @@ D(if (!fVolume->CheckBlock(block, offset + size)) return NULL;);
} else { } else {
D( D(
if (offset + size > kSmallDataContainerSize) { if (offset + size > kSmallDataContainerSize) {
FATAL(("DataContainer: Data access exceeds small buffer.\n")); FATAL("DataContainer: Data access exceeds small buffer.\n");
PANIC("DataContainer: Data access exceeds small buffer."); PANIC("DataContainer: Data access exceeds small buffer.");
return NULL; return NULL;
} }
@@ -349,7 +349,7 @@ DataContainer::_ResizeLastBlock(size_t newSize)
? B_OK : B_BAD_VALUE); ? B_OK : B_BAD_VALUE);
D( D(
if (!_IsBlockMode()) { if (!_IsBlockMode()) {
FATAL(("Call of _ResizeLastBlock() in small buffer mode.\n")); FATAL("Call of _ResizeLastBlock() in small buffer mode.\n");
PANIC("Call of _ResizeLastBlock() in small buffer mode."); PANIC("Call of _ResizeLastBlock() in small buffer mode.");
return B_ERROR; return B_ERROR;
} }
@@ -25,7 +25,7 @@ Directory::~Directory()
// delete all entries // delete all entries
while (Entry *entry = fEntries.First()) { while (Entry *entry = fEntries.First()) {
if (DeleteEntry(entry) != B_OK) { if (DeleteEntry(entry) != B_OK) {
FATAL(("Could not delete all entries in directory.\n")); FATAL("Could not delete all entries in directory.\n");
break; break;
} }
} }
@@ -234,7 +234,7 @@ Directory::DeleteEntry(Entry *entry)
if (error == B_OK) if (error == B_OK)
delete entry; delete entry;
else { else {
FATAL("Failed to Unlink() entry %p from node %Ld!\n", entry, FATAL("Failed to Unlink() entry %p from node %" B_PRIdINO "!\n", entry,
entry->GetNode()->GetID()); entry->GetNode()->GetID());
AddEntry(entry); AddEntry(entry);
} }
@@ -75,11 +75,11 @@ void
Index::Dump() Index::Dump()
{ {
D( D(
PRINT(("Index: `%s', type: %lx\n", GetName(), GetType())); PRINT("Index: `%s', type: %lx\n", GetName(), GetType());
for (IndexEntryIterator it(this); it.GetCurrent(); it.GetNext()) { for (IndexEntryIterator it(this); it.GetCurrent(); it.GetNext()) {
Entry *entry = it.GetCurrent(); Entry *entry = it.GetCurrent();
PRINT((" entry: `%s', dir: %Ld\n", entry->GetName(), PRINT(" entry: `%s', dir: %Ld\n", entry->GetName(),
entry->GetParent()->GetID())); entry->GetParent()->GetID());
} }
) )
} }
@@ -70,7 +70,7 @@ Node::~Node()
while (Attribute *attribute = fAttributes.First()) { while (Attribute *attribute = fAttributes.First()) {
status_t error = DeleteAttribute(attribute); status_t error = DeleteAttribute(attribute);
if (error != B_OK) { if (error != B_OK) {
FATAL(("Node::~Node(): Failed to delete attribute!\n")); FATAL("Node::~Node(): Failed to delete attribute!\n");
break; break;
} }
} }
@@ -114,7 +114,7 @@ Node::RemoveReference()
status_t status_t
Node::Link(Entry *entry) Node::Link(Entry *entry)
{ {
PRINT(("Node[%Ld]::Link(): %ld ->...\n", fID, fRefCount)); PRINT("Node[%Ld]::Link(): %" B_PRId32 " ->...\n", fID, fRefCount);
fReferrers.Insert(entry); fReferrers.Insert(entry);
status_t error = AddReference(); status_t error = AddReference();
@@ -128,7 +128,7 @@ PRINT(("Node[%Ld]::Link(): %ld ->...\n", fID, fRefCount));
status_t status_t
Node::Unlink(Entry *entry) Node::Unlink(Entry *entry)
{ {
PRINT(("Node[%Ld]::Unlink(): %ld ->...\n", fID, fRefCount)); PRINT("Node[%Ld]::Unlink(): %" B_PRId32 " ->...\n", fID, fRefCount);
RemoveReference(); RemoveReference();
fReferrers.Remove(entry); fReferrers.Remove(entry);
+48 -48
View File
@@ -236,7 +236,7 @@ enum ops {
enum match { enum match {
NO_MATCH = 0, NO_MATCH = 0,
MATCH_OK = 1, MATCH_OK = 1,
MATCH_BAD_PATTERN = -2, MATCH_BAD_PATTERN = -2,
MATCH_INVALID_CHARACTER MATCH_INVALID_CHARACTER
}; };
@@ -391,7 +391,7 @@ class Operator : public Term {
//--------------------------------- //---------------------------------
void void
skipWhitespace(char **expr, int32 skip = 0) skipWhitespace(char **expr, int32 skip = 0)
{ {
char *string = (*expr) + skip; char *string = (*expr) + skip;
@@ -400,7 +400,7 @@ skipWhitespace(char **expr, int32 skip = 0)
} }
void void
skipWhitespaceReverse(char **expr,char *stop) skipWhitespaceReverse(char **expr,char *stop)
{ {
char *string = *expr; char *string = *expr;
@@ -638,7 +638,7 @@ matchString(char *pattern, char *string)
if (string[0]) if (string[0])
return NO_MATCH; return NO_MATCH;
return MATCH_OK; return MATCH_OK;
} }
@@ -689,7 +689,7 @@ Equation::Equation(char **expr)
// attribute string is empty (which is not allowed) // attribute string is empty (which is not allowed)
if (start > end) if (start > end)
return; return;
// at this point, "start" points to the beginning of the string, "end" points // at this point, "start" points to the beginning of the string, "end" points
// to the last character of the string, and "string" points to the first // to the last character of the string, and "string" points to the first
// character of the equation symbol // character of the equation symbol
@@ -710,7 +710,7 @@ Equation::Equation(char **expr)
return; return;
fOp = OP_UNEQUAL; fOp = OP_UNEQUAL;
break; break;
// any invalid characters will be rejected // any invalid characters will be rejected
default: default:
*expr = string; *expr = string;
@@ -733,7 +733,7 @@ Equation::Equation(char **expr)
// string is quoted (start has to be on the beginning of a string) // string is quoted (start has to be on the beginning of a string)
if (ParseQuotedString(&start, &end) < B_OK) if (ParseQuotedString(&start, &end) < B_OK)
return; return;
string = end + 2; string = end + 2;
skipWhitespace(&string); skipWhitespace(&string);
} else { } else {
@@ -743,7 +743,7 @@ Equation::Equation(char **expr)
end = string - 1; end = string - 1;
skipWhitespaceReverse(&end, start); skipWhitespaceReverse(&end, start);
} }
// at this point, "start" will point to the first character of the value, // at this point, "start" will point to the first character of the value,
// "end" will point to its last character, and "start" to the first non- // "end" will point to its last character, and "start" to the first non-
// whitespace character after the value string // whitespace character after the value string
@@ -776,7 +776,7 @@ Equation::~Equation()
} }
status_t status_t
Equation::InitCheck() Equation::InitCheck()
{ {
if (fAttribute == NULL if (fAttribute == NULL
@@ -788,13 +788,13 @@ Equation::InitCheck()
} }
status_t status_t
Equation::ParseQuotedString(char **_start, char **_end) Equation::ParseQuotedString(char **_start, char **_end)
{ {
char *start = *_start; char *start = *_start;
char quote = *start++; char quote = *start++;
char *end = start; char *end = start;
for (;*end && *end != quote;end++) { for (;*end && *end != quote;end++) {
if (*end == '\\') if (*end == '\\')
end++; end++;
@@ -831,7 +831,7 @@ Equation::CopyString(char *start, char *end)
} }
status_t status_t
Equation::ConvertValue(type_code type) Equation::ConvertValue(type_code type)
{ {
// Has the type already been converted? // Has the type already been converted?
@@ -874,7 +874,7 @@ Equation::ConvertValue(type_code type)
fSize = sizeof(double); fSize = sizeof(double);
break; break;
default: default:
FATAL("query value conversion to 0x%lx requested!\n", type); FATAL("query value conversion to 0x%" B_PRIx32 " requested!\n", type);
// should we fail here or just do a safety int32 conversion? // should we fail here or just do a safety int32 conversion?
return B_ERROR; return B_ERROR;
} }
@@ -926,11 +926,11 @@ Equation::CompareTo(const uint8 *value, uint16 size)
} }
void void
Equation::Complement() Equation::Complement()
{ {
D(if (fOp <= OP_EQUATION || fOp > OP_LESS_THAN_OR_EQUAL) { D(if (fOp <= OP_EQUATION || fOp > OP_LESS_THAN_OR_EQUAL) {
FATAL(("op out of range!")); FATAL("op out of range!");
return; return;
}); });
@@ -1025,7 +1025,7 @@ Equation::Match(Entry *entry, Node* node, const char *attributeName, int32 type,
} }
void void
Equation::CalculateScore(IndexWrapper &index) Equation::CalculateScore(IndexWrapper &index)
{ {
// As always, these values could be tuned and refined. // As always, these values could be tuned and refined.
@@ -1063,7 +1063,7 @@ status_t
Equation::PrepareQuery(Volume */*volume*/, IndexWrapper &index, IndexIterator **iterator, bool queryNonIndexed) Equation::PrepareQuery(Volume */*volume*/, IndexWrapper &index, IndexIterator **iterator, bool queryNonIndexed)
{ {
status_t status = index.SetTo(fAttribute); status_t status = index.SetTo(fAttribute);
// if we should query attributes without an index, we can just proceed here // if we should query attributes without an index, we can just proceed here
if (status < B_OK && !queryNonIndexed) if (status < B_OK && !queryNonIndexed)
return B_ENTRY_NOT_FOUND; return B_ENTRY_NOT_FOUND;
@@ -1144,7 +1144,7 @@ Equation::PrepareQuery(Volume */*volume*/, IndexWrapper &index, IndexIterator **
} }
status_t status_t
Equation::GetNextMatching(Volume *volume, IndexIterator *iterator, Equation::GetNextMatching(Volume *volume, IndexIterator *iterator,
struct dirent *dirent, size_t bufferSize) struct dirent *dirent, size_t bufferSize)
{ {
@@ -1292,20 +1292,20 @@ Operator::Match(Entry *entry, Node* node, const char *attribute,
} }
void void
Operator::Complement() Operator::Complement()
{ {
if (fOp == OP_AND) if (fOp == OP_AND)
fOp = OP_OR; fOp = OP_OR;
else else
fOp = OP_AND; fOp = OP_AND;
fLeft->Complement(); fLeft->Complement();
fRight->Complement(); fRight->Complement();
} }
void void
Operator::CalculateScore(IndexWrapper &index) Operator::CalculateScore(IndexWrapper &index)
{ {
fLeft->CalculateScore(index); fLeft->CalculateScore(index);
@@ -1313,26 +1313,26 @@ Operator::CalculateScore(IndexWrapper &index)
} }
int32 int32
Operator::Score() const Operator::Score() const
{ {
if (fOp == OP_AND) { if (fOp == OP_AND) {
// return the one with the better score // return the one with the better score
if (fRight->Score() > fLeft->Score()) if (fRight->Score() > fLeft->Score())
return fRight->Score(); return fRight->Score();
return fLeft->Score(); return fLeft->Score();
} }
// for OP_OR, be honest, and return the one with the worse score // for OP_OR, be honest, and return the one with the worse score
if (fRight->Score() < fLeft->Score()) if (fRight->Score() < fLeft->Score())
return fRight->Score(); return fRight->Score();
return fLeft->Score(); return fLeft->Score();
} }
status_t status_t
Operator::InitCheck() Operator::InitCheck()
{ {
if ((fOp != OP_AND && fOp != OP_OR) if ((fOp != OP_AND && fOp != OP_OR)
@@ -1363,7 +1363,7 @@ Operator::Copy() const
Term *term = new Term(equation); Term *term = new Term(equation);
if (term == NULL) if (term == NULL)
delete equation; delete equation;
return term; return term;
} }
@@ -1438,10 +1438,10 @@ Expression::Expression(char *expr)
{ {
if (expr == NULL) if (expr == NULL)
return; return;
fTerm = ParseOr(&expr); fTerm = ParseOr(&expr);
if (fTerm != NULL && fTerm->InitCheck() < B_OK) { if (fTerm != NULL && fTerm->InitCheck() < B_OK) {
FATAL(("Corrupt tree in expression!\n")); FATAL("Corrupt tree in expression!\n");
delete fTerm; delete fTerm;
fTerm = NULL; fTerm = NULL;
} }
@@ -1449,7 +1449,7 @@ Expression::Expression(char *expr)
fTerm->PrintToStream(); fTerm->PrintToStream();
D(__out("\n")); D(__out("\n"));
if (*expr != '\0') if (*expr != '\0')
PRINT(("Unexpected end of string: \"%s\"!\n", expr)); PRINT("Unexpected end of string: \"%s\"!\n", expr);
}); });
fPosition = expr; fPosition = expr;
} }
@@ -1471,7 +1471,7 @@ Expression::ParseEquation(char **expr)
skipWhitespace(expr, 1); skipWhitespace(expr, 1);
if (**expr != '(') if (**expr != '(')
return NULL; return NULL;
nott = true; nott = true;
} }
@@ -1480,16 +1480,16 @@ Expression::ParseEquation(char **expr)
return NULL; return NULL;
} else if (**expr == '(') { } else if (**expr == '(') {
skipWhitespace(expr, 1); skipWhitespace(expr, 1);
Term *term = ParseOr(expr); Term *term = ParseOr(expr);
skipWhitespace(expr); skipWhitespace(expr);
if (**expr != ')') { if (**expr != ')') {
delete term; delete term;
return NULL; return NULL;
} }
// If the term is negated, we just complement the tree, to get // If the term is negated, we just complement the tree, to get
// rid of the not, a.k.a. DeMorgan's Law. // rid of the not, a.k.a. DeMorgan's Law.
if (nott) if (nott)
@@ -1557,11 +1557,11 @@ Expression::ParseOr(char **expr)
} }
bool bool
Expression::IsOperator(char **expr, char op) Expression::IsOperator(char **expr, char op)
{ {
char *string = *expr; char *string = *expr;
if (*string == op && *(string + 1) == op) { if (*string == op && *(string + 1) == op) {
*expr += 2; *expr += 2;
return true; return true;
@@ -1570,7 +1570,7 @@ Expression::IsOperator(char **expr, char op)
} }
status_t status_t
Expression::InitCheck() Expression::InitCheck()
{ {
if (fTerm == NULL) if (fTerm == NULL)
@@ -1652,14 +1652,14 @@ Query::Rewind()
stack.Push(op->Left()); stack.Push(op->Left());
} }
} else if (term->Op() == OP_EQUATION || fStack.Push((Equation *)term) < B_OK) } else if (term->Op() == OP_EQUATION || fStack.Push((Equation *)term) < B_OK)
FATAL(("Unknown term on stack or stack error")); FATAL("Unknown term on stack or stack error");
} }
return B_OK; return B_OK;
} }
status_t status_t
Query::GetNextEntry(struct dirent *dirent, size_t size) Query::GetNextEntry(struct dirent *dirent, size_t size)
{ {
// If we don't have an equation to use yet/anymore, get a new one // If we don't have an equation to use yet/anymore, get a new one
@@ -1688,7 +1688,7 @@ Query::GetNextEntry(struct dirent *dirent, size_t size)
} }
void void
Query::SetLiveMode(port_id port, int32 token) Query::SetLiveMode(port_id port, int32 token)
{ {
fPort = port; fPort = port;
@@ -1719,13 +1719,13 @@ send_entry_notification(port_id port, int32 token, Volume* volume, Entry* entry,
} }
void void
Query::LiveUpdate(Entry *entry, Node* node, const char *attribute, int32 type, Query::LiveUpdate(Entry *entry, Node* node, const char *attribute, int32 type,
const uint8 *oldKey, size_t oldLength, const uint8 *newKey, const uint8 *oldKey, size_t oldLength, const uint8 *newKey,
size_t newLength) size_t newLength)
{ {
PRINT(("%p->Query::LiveUpdate(%p, %p, \"%s\", 0x%lx, %p, %lu, %p, %lu)\n", PRINT("%p->Query::LiveUpdate(%p, %p, \"%s\", 0x%lx, %p, %lu, %p, %lu)\n",
this, entry, node, attribute, type, oldKey, oldLength, newKey, newLength)); this, entry, node, attribute, type, oldKey, oldLength, newKey, newLength);
if (fPort < 0 || fExpression == NULL || node == NULL || attribute == NULL) if (fPort < 0 || fExpression == NULL || node == NULL || attribute == NULL)
return; return;
@@ -1748,18 +1748,18 @@ this, entry, node, attribute, type, oldKey, oldLength, newKey, newLength));
type, oldKey, oldLength); type, oldKey, oldLength);
status_t newStatus = fExpression->Root()->Match(entry, node, attribute, status_t newStatus = fExpression->Root()->Match(entry, node, attribute,
type, newKey, newLength); type, newKey, newLength);
PRINT((" oldStatus: 0x%lx, newStatus: 0x%lx\n", oldStatus, newStatus)); PRINT(" oldStatus: 0x%lx, newStatus: 0x%lx\n", oldStatus, newStatus);
bool created; bool created;
if (oldStatus == MATCH_OK && newStatus == MATCH_OK) { if (oldStatus == MATCH_OK && newStatus == MATCH_OK) {
// only send out a notification if the name was changed // only send out a notification if the name was changed
if (oldKey == NULL || strcmp(attribute,"name")) if (oldKey == NULL || strcmp(attribute,"name"))
return; return;
if (entry) { if (entry) {
// entry should actually always be given, when the changed // entry should actually always be given, when the changed
// attribute is the entry name // attribute is the entry name
PRINT(("notification: old: removed\n")); PRINT("notification: old: removed\n");
notify_query_entry_removed(fPort, fToken, fVolume->GetID(), notify_query_entry_removed(fPort, fToken, fVolume->GetID(),
entry->GetParent()->GetID(), (const char *)oldKey, entry->GetParent()->GetID(), (const char *)oldKey,
entry->GetNode()->GetID()); entry->GetNode()->GetID());
@@ -1776,7 +1776,7 @@ PRINT(("notification: old: removed\n"));
// We send a notification for the given entry, if any, or otherwise for // We send a notification for the given entry, if any, or otherwise for
// all entries referring to the node; // all entries referring to the node;
if (entry) { if (entry) {
PRINT(("notification: new: %s\n", (created ? "created" : "removed"))); PRINT("notification: new: %s\n", (created ? "created" : "removed"));
send_entry_notification(fPort, fToken, fVolume, entry, created); send_entry_notification(fPort, fToken, fVolume, entry, created);
} else { } else {
entry = node->GetFirstReferrer(); entry = node->GetFirstReferrer();
@@ -382,7 +382,7 @@ Volume::GetVNode(Node *node)
status_t error = (fMounted ? GetVNode(node->GetID(), &dummy) status_t error = (fMounted ? GetVNode(node->GetID(), &dummy)
: B_BAD_VALUE ); : B_BAD_VALUE );
if (error == B_OK && dummy != node) { if (error == B_OK && dummy != node) {
FATAL("Two Nodes have the same ID: %Ld!\n", node->GetID()); FATAL("Two Nodes have the same ID: %" B_PRIdINO "!\n", node->GetID());
PutVNode(dummy); PutVNode(dummy);
error = B_ERROR; error = B_ERROR;
} }
@@ -311,7 +311,7 @@ ramfs_ioctl(fs_volume* _volume, fs_vnode* /*node*/, void* /*cookie*/,
if (buffer) { if (buffer) {
if (VolumeReadLocker locker = volume) { if (VolumeReadLocker locker = volume) {
const char *name = (const char*)buffer; const char *name = (const char*)buffer;
PRINT((" RAMFS_IOCTL_DUMP_INDEX, `%s'\n", name)); PRINT(" RAMFS_IOCTL_DUMP_INDEX, `%s'\n", name);
IndexDirectory *indexDir = volume->GetIndexDirectory(); IndexDirectory *indexDir = volume->GetIndexDirectory();
if (indexDir) { if (indexDir) {
if (Index *index = indexDir->FindIndex(name)) if (Index *index = indexDir->FindIndex(name))
@@ -377,7 +377,7 @@ ramfs_read_symlink(fs_volume* _volume, fs_vnode* _node, char *buffer,
memcpy(buffer, symLink->GetLinkedPath(), toRead); memcpy(buffer, symLink->GetLinkedPath(), toRead);
*bufferSize = toRead; *bufferSize = toRead;
} else { } else {
FATAL("Node %Ld pretends to be a SymLink, but isn't!\n", FATAL("Node %" B_PRIdINO " pretends to be a SymLink, but isn't!\n",
node->GetID()); node->GetID());
error = B_BAD_VALUE; error = B_BAD_VALUE;
} }
@@ -958,7 +958,7 @@ ramfs_read(fs_volume* _volume, fs_vnode* _node, void* _cookie, off_t pos,
if (File *file = dynamic_cast<File*>(node)) if (File *file = dynamic_cast<File*>(node))
error = file->ReadAt(pos, buffer, *bufferSize, bufferSize); error = file->ReadAt(pos, buffer, *bufferSize, bufferSize);
else { else {
FATAL("Node %Ld pretends to be a File, but isn't!\n", FATAL("Node %" B_PRIdINO " pretends to be a File, but isn't!\n",
node->GetID()); node->GetID());
error = B_BAD_VALUE; error = B_BAD_VALUE;
} }
@@ -1000,7 +1000,7 @@ ramfs_write(fs_volume* _volume, fs_vnode* _node, void* _cookie, off_t pos,
error = file->WriteAt(pos, buffer, *bufferSize, error = file->WriteAt(pos, buffer, *bufferSize,
bufferSize); bufferSize);
} else { } else {
FATAL("Node %Ld pretends to be a File, but isn't!\n", FATAL("Node %" B_PRIdINO " pretends to be a File, but isn't!\n",
node->GetID()); node->GetID());
error = B_BAD_VALUE; error = B_BAD_VALUE;
} }
@@ -1064,10 +1064,10 @@ fGetNextCounter++;
*entryName = entry->GetName(); *entryName = entry->GetName();
} }
} }
PRINT(("EntryIterator %ld, GetNext() counter: %ld, entry: %p (%Ld)\n", PRINT("EntryIterator %" B_PRId32 ", GetNext() counter: %" B_PRId32 ", entry: %p (%Ld)\n",
fIteratorID, fGetNextCounter, fIterator.GetCurrent(), fIteratorID, fGetNextCounter, fIterator.GetCurrent(),
(fIterator.GetCurrent() (fIterator.GetCurrent()
? fIterator.GetCurrent()->GetNode()->GetID() : -1))); ? fIterator.GetCurrent()->GetNode()->GetID() : -1));
return error; return error;
} }
@@ -1218,7 +1218,7 @@ ramfs_open_dir(fs_volume* /*fs*/, fs_vnode* _node, void** _cookie)
if (error == B_OK) { if (error == B_OK) {
dir = dynamic_cast<Directory*>(node); dir = dynamic_cast<Directory*>(node);
if (!dir) { if (!dir) {
FATAL("Node %Ld pretends to be a Directory, but isn't!\n", FATAL("Node %" B_PRIdINO " pretends to be a Directory, but isn't!\n",
node->GetID()); node->GetID());
error = B_NOT_A_DIRECTORY; error = B_NOT_A_DIRECTORY;
} }
@@ -1284,7 +1284,7 @@ ramfs_read_dir(fs_volume* _volume, fs_vnode* DARG(_node), void* _cookie,
ino_t nodeID = -1; ino_t nodeID = -1;
const char *name = NULL; const char *name = NULL;
if (cookie->GetNext(&nodeID, &name) == B_OK) { if (cookie->GetNext(&nodeID, &name) == B_OK) {
PRINT((" entry: `%s'\n", name)); PRINT(" entry: `%s'\n", name);
size_t nameLen = strlen(name); size_t nameLen = strlen(name);
// check, whether the entry fits into the buffer, // check, whether the entry fits into the buffer,
// and fill it in // and fill it in
@@ -2018,8 +2018,8 @@ ramfs_open_query(fs_volume* _volume, const char *queryString, uint32 flags,
port_id port, uint32 token, void** _cookie) port_id port, uint32 token, void** _cookie)
{ {
FUNCTION_START(); FUNCTION_START();
PRINT(("query = \"%s\", flags = %lu, port_id = %ld, token = %ld\n", PRINT("query = \"%s\", flags = %lu, port_id = %" B_PRId32 ", token = %" B_PRId32 "\n",
queryString, flags, port, token)); queryString, flags, port, token);
Volume* volume = (Volume*)_volume->private_volume; Volume* volume = (Volume*)_volume->private_volume;
@@ -2035,8 +2035,8 @@ ramfs_open_query(fs_volume* _volume, const char *queryString, uint32 flags,
ObjectDeleter<Expression> expressionDeleter(expression); ObjectDeleter<Expression> expressionDeleter(expression);
if (expression->InitCheck() < B_OK) { if (expression->InitCheck() < B_OK) {
WARN(("Could not parse query, stopped at: \"%s\"\n", WARN("Could not parse query, stopped at: \"%s\"\n",
expression->Position())); expression->Position());
RETURN_ERROR(B_BAD_VALUE); RETURN_ERROR(B_BAD_VALUE);
} }
@@ -2127,12 +2127,12 @@ ramfs_std_ops(int32 op, ...)
case B_MODULE_INIT: case B_MODULE_INIT:
{ {
init_debugging(); init_debugging();
PRINT(("ramfs_std_ops(): B_MODULE_INIT\n")); PRINT("ramfs_std_ops(): B_MODULE_INIT\n");
return B_OK; return B_OK;
} }
case B_MODULE_UNINIT: case B_MODULE_UNINIT:
PRINT(("ramfs_std_ops(): B_MODULE_UNINIT\n")); PRINT("ramfs_std_ops(): B_MODULE_UNINIT\n");
exit_debugging(); exit_debugging();
return B_OK; return B_OK;