hrev45657 adds 5 changesets to branch 'master' old head: fe1f74ab54b33a520b7a2687fc241422252e5f14 new head: bc8c7d615d95fbca5192912189c934510ee72a92 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=bc8c7d6+%5Efe1f74a ---------------------------------------------------------------------------- 2a8d81c: bfsinfo: fixes 64 bit warnings aff59d3: hey: fixes 64 bit warnings 7074a7c: reindex: fixes 64 bit warnings 0059a07: roster: fixes 64 bit warnings bc8c7d6: translate: fixes 64 bit warnings [ Jérôme Duval <jerome.duval@xxxxxxxxx> ] ---------------------------------------------------------------------------- 11 files changed, 187 insertions(+), 146 deletions(-) src/bin/bfs_tools/bfsinfo.cpp | 46 ++++++------ src/bin/bfs_tools/lib/BPlusTree.cpp | 13 ++-- src/bin/bfs_tools/lib/Bitmap.cpp | 8 ++- src/bin/bfs_tools/lib/Disk.cpp | 54 ++++++++------ src/bin/bfs_tools/lib/Inode.cpp | 21 +++--- src/bin/bfs_tools/lib/bfs.h | 2 +- src/bin/bfs_tools/lib/dump.cpp | 124 +++++++++++++++++--------------- src/bin/hey.cpp | 42 ++++++----- src/bin/reindex.cpp | 6 +- src/bin/roster.cpp | 4 +- src/bin/translate.cpp | 13 ++-- ############################################################################ Commit: 2a8d81c2913b3e23f9ea101b5a188411830a3dfd URL: http://cgit.haiku-os.org/haiku/commit/?id=2a8d81c Author: Jérôme Duval <jerome.duval@xxxxxxxxx> Date: Fri May 10 17:31:22 2013 UTC bfsinfo: fixes 64 bit warnings ---------------------------------------------------------------------------- diff --git a/src/bin/bfs_tools/bfsinfo.cpp b/src/bin/bfs_tools/bfsinfo.cpp index 44b64cc..4c9a565 100644 --- a/src/bin/bfs_tools/bfsinfo.cpp +++ b/src/bin/bfs_tools/bfsinfo.cpp @@ -37,10 +37,10 @@ dump_bplustree(Disk &disk, BPositionIO *file, off_t size, bool hexDump) dump_bplustree_header(header); bplustree_node *node = (bplustree_node *)(buffer + nodeSize); - while ((int32)node < (int32)buffer + size) { + while ((addr_t)node < (addr_t)buffer + size) { printf("\n\n-------------------\n" - "** node at offset: %ld\n** used: %ld bytes\n", - int32(node) - int32(buffer), node->Used()); + "** node at offset: %" B_PRIuADDR "\n** used: %" B_PRId32 " bytes" + "\n", (addr_t)node - (addr_t)buffer, node->Used()); dump_bplustree_node(node, header, &disk); if (hexDump) { @@ -48,7 +48,7 @@ dump_bplustree(Disk &disk, BPositionIO *file, off_t size, bool hexDump) dump_block((char *)node, header->node_size, 0); } - node = (bplustree_node *)(int32(node) + nodeSize); + node = (bplustree_node *)((addr_t)node + nodeSize); } } @@ -79,11 +79,11 @@ dump_indirect_stream(Disk &disk, bfs_inode *node, bool showOffsets) if (runs[i].IsZero()) return; - printf(" indirect[%02ld] = ", i); + printf(" indirect[%02" B_PRId32 "] = ", i); char buffer[256]; if (showOffsets) - snprintf(buffer, sizeof(buffer), " %16lld", offset); + snprintf(buffer, sizeof(buffer), " %16" B_PRIdOFF, offset); else buffer[0] = '\0'; @@ -184,25 +184,27 @@ main(int argc, char **argv) printf(" Name:\t\t\t\"%s\"\n", disk.SuperBlock()->name); printf(" (disk is %s)\n\n", disk.ValidateSuperBlock() == B_OK ? "valid" : "invalid!!"); - printf(" Block Size:\t\t%ld bytes\n", disk.BlockSize()); - printf(" Number of Blocks:\t%12Lu\t%10g MB\n", disk.NumBlocks(), - disk.NumBlocks() * disk.BlockSize() / (1024.0*1024)); + printf(" Block Size:\t\t%" B_PRIu32 " bytes\n", disk.BlockSize()); + printf(" Number of Blocks:\t%12" B_PRIdOFF "\t%10g MB\n", + disk.NumBlocks(), disk.NumBlocks() * disk.BlockSize() + / (1024.0*1024)); if (disk.BlockBitmap() != NULL) { - printf(" Used Blocks:\t\t%12Lu\t%10g MB\n", + printf(" Used Blocks:\t\t%12" B_PRIdOFF "\t%10g MB\n", disk.BlockBitmap()->UsedBlocks(), disk.BlockBitmap()->UsedBlocks() * disk.BlockSize() / (1024.0*1024)); - printf(" Free Blocks:\t\t%12Lu\t%10g MB\n", + printf(" Free Blocks:\t\t%12" B_PRIdOFF "\t%10g MB\n", disk.BlockBitmap()->FreeBlocks(), disk.BlockBitmap()->FreeBlocks() * disk.BlockSize() / (1024.0*1024)); } int32 size = (disk.AllocationGroups() * disk.SuperBlock()->blocks_per_ag); - printf(" Bitmap Size:\t\t%ld bytes (%ld blocks, %ld per allocation " - "group)\n", disk.BlockSize() * size, size, + printf(" Bitmap Size:\t\t%" B_PRIu32 " bytes (%" B_PRId32 " blocks, %" + B_PRId32 " per allocation group)\n", disk.BlockSize() * size, size, disk.SuperBlock()->blocks_per_ag); - printf(" Allocation Groups:\t%lu\n\n", disk.AllocationGroups()); + printf(" Allocation Groups:\t%" B_PRIu32 "\n\n", + disk.AllocationGroups()); dump_block_run(" Log:\t\t\t", disk.Log()); printf(" (was %s)\n\n", disk.SuperBlock()->flags == SUPER_BLOCK_CLEAN ? "cleanly unmounted" : "not unmounted cleanly!"); @@ -260,8 +262,8 @@ main(int argc, char **argv) } if (dumpInode) { - printf("Inode at block %Ld:\n-----------------------------------------" - "\n", disk.ToBlock(run)); + printf("Inode at block %" B_PRIdOFF ":\n------------------------------" + "-----------\n", disk.ToBlock(run)); dump_inode(inode, (bfs_inode *)buffer, showOffsets); dump_indirect_stream(disk, (bfs_inode *)buffer, showOffsets); dump_small_data(inode); @@ -269,8 +271,8 @@ main(int argc, char **argv) } if (dumpBTree && inode) { - printf("B+Tree at block %Ld:\n----------------------------------------" - "-\n", disk.ToBlock(run)); + printf("B+Tree at block %" B_PRIdOFF ":\n-----------------------------" + "------------\n", disk.ToBlock(run)); if (inode->IsDirectory() || inode->IsAttributeDirectory()) { dump_bplustree(disk, (Directory *)inode, inode->Size(), dumpHex); putchar('\n'); @@ -279,8 +281,8 @@ main(int argc, char **argv) } if (validateBTree && inode) { - printf("Validating B+Tree at block %Ld:\n-----------------------------" - "------------\n", disk.ToBlock(run)); + printf("Validating B+Tree at block %" B_PRIdOFF ":\n------------------" + "-----------------------\n", disk.ToBlock(run)); if (inode->IsDirectory() || inode->IsAttributeDirectory()) { BPlusTree *tree; if (((Directory *)inode)->GetTree(&tree) == B_OK) { @@ -294,8 +296,8 @@ main(int argc, char **argv) } if (dumpHex) { - printf("Hexdump from inode at block %Ld:\n-----------------------------" - "------------\n", disk.ToBlock(run)); + printf("Hexdump from inode at block %" B_PRIdOFF ":\n-----------------" + "------------------------\n", disk.ToBlock(run)); dump_block(buffer, disk.BlockSize()); putchar('\n'); } diff --git a/src/bin/bfs_tools/lib/BPlusTree.cpp b/src/bin/bfs_tools/lib/BPlusTree.cpp index 9493593..60255eb 100644 --- a/src/bin/bfs_tools/lib/BPlusTree.cpp +++ b/src/bin/bfs_tools/lib/BPlusTree.cpp @@ -250,14 +250,14 @@ BPlusTree::Validate(bool verbose) while (true) { if (!stack.Pop(&info)) { if (verbose) { - printf(" %ld B+tree node(s) processed (%ld free node(s)).\n", - count, freeCount); + printf(" %" B_PRId32 " B+tree node(s) processed (%" B_PRId32 + " free node(s)).\n", count, freeCount); } return B_OK; } if (!info.free && verbose && ++count % 10 == 0) - printf(" %ld%s1A\n", count, escape); + printf(" %" B_PRId32 "%s1A\n", count, escape); else if (info.free) freeCount++; @@ -265,7 +265,9 @@ BPlusTree::Validate(bool verbose) if ((node = fCache.Get(info.offset)) == NULL || !info.free && !CheckNode(node)) { if (verbose) { - fprintf(stderr," B+Tree: Could not get data at position %Ld (referenced by node at %Ld)\n",info.offset,info.from); + fprintf(stderr," B+Tree: Could not get data at position %" + B_PRIdOFF " (referenced by node at %" B_PRIdOFF ")\n", + info.offset, info.from); if ((node = fCache.Get(info.from)) != NULL) dump_bplustree_node(node,fHeader); } @@ -350,7 +352,8 @@ status_t BPlusTree::Goto(int8 to) else { if (node->all_key_length > fNodeSize - || (uint32)node->Values() > (uint32)node + fNodeSize - 8 * node->all_key_count) + || (addr_t)node->Values() > (addr_t)node + fNodeSize + - 8 * node->all_key_count) return B_ERROR; pos = *node->Values(); diff --git a/src/bin/bfs_tools/lib/Bitmap.cpp b/src/bin/bfs_tools/lib/Bitmap.cpp index 53567da..8fbe8c4 100644 --- a/src/bin/bfs_tools/lib/Bitmap.cpp +++ b/src/bin/bfs_tools/lib/Bitmap.cpp @@ -138,8 +138,8 @@ Bitmap::BackupSetAt(off_t block, bool used) { uint32 index = block / 32; if (index > fByteSize / 4) { - fprintf(stderr, "Bitmap::BackupSetAt(): Block %Ld outside bitmap!\n", - block); + fprintf(stderr, "Bitmap::BackupSetAt(): Block %" B_PRIdOFF " outside " + "bitmap!\n", block); return false; } @@ -251,7 +251,9 @@ Bitmap::CompareWithBackup() { for (int32 i = fByteSize / 4;i-- > 0;) { if (fBitmap[i] != fBackupBitmap[i]) { - printf("differ at %ld (block %ld) -> bitmap = %08lx, backup = %08lx\n",i,i*32,fBitmap[i],fBackupBitmap[i]); + printf("differ at %" B_PRId32 " (block %" B_PRId32 ") -> bitmap = " + "%08" B_PRIx32 ", backup = %08" B_PRIx32 "\n", i, i * 32, + fBitmap[i], fBackupBitmap[i]); } } return B_OK; diff --git a/src/bin/bfs_tools/lib/Disk.cpp b/src/bin/bfs_tools/lib/Disk.cpp index 5d0fd07..b082938 100644 --- a/src/bin/bfs_tools/lib/Disk.cpp +++ b/src/bin/bfs_tools/lib/Disk.cpp @@ -147,8 +147,10 @@ Disk::Disk(const char *deviceName, bool rawMode, off_t start, off_t stop) } close(device); - if (fSize == 0LL) - fprintf(stderr,"Disk: Invalid file size (%Ld bytes)!\n",fSize); + if (fSize == 0LL) { + fprintf(stderr,"Disk: Invalid file size (%" B_PRIdOFF " bytes)!\n", + fSize); + } if (rawMode && ScanForSuperBlock(start, stop) < B_OK) { fFile.Unset(); @@ -240,7 +242,8 @@ Disk::DumpBootBlockToFile() status_t Disk::ScanForSuperBlock(off_t start, off_t stop) { - printf("Disk size %Ld bytes, %.2f GB\n", fSize, 1.0 * fSize / (1024*1024*1024)); + printf("Disk size %" B_PRIdOFF " bytes, %.2f GB\n", fSize, 1.0 * fSize + / (1024*1024*1024)); uint32 blockSize = 4096; char buffer[blockSize + 1024]; @@ -252,12 +255,15 @@ Disk::ScanForSuperBlock(off_t start, off_t stop) BList superBlocks; - printf("Scanning Disk from %Ld to %Ld\n", start, stop); + printf("Scanning Disk from %" B_PRIdOFF " to %" B_PRIdOFF "\n", start, + stop); for (off_t offset = start; offset < stop; offset += blockSize) { - if (((offset-start) % (blockSize * 100)) == 0) - printf(" %12Ld, %.2f GB %s1A\n",offset,1.0 * offset / (1024*1024*1024),escape); + if (((offset-start) % (blockSize * 100)) == 0) { + printf(" %12" B_PRIdOFF ", %.2f GB %s1A\n", offset, + 1.0 * offset / (1024*1024*1024),escape); + } ssize_t bytes = fBufferedFile->ReadAt(offset, buffer, blockSize + 1024); if (bytes < B_OK) @@ -274,7 +280,8 @@ Disk::ScanForSuperBlock(off_t start, off_t stop) && super->magic2 == (int32)SUPER_BLOCK_MAGIC2 && super->magic3 == (int32)SUPER_BLOCK_MAGIC3) { - printf("\n(%ld) *** BFS superblock found at: %Ld\n",superBlocks.CountItems() + 1,offset); + printf("\n(%" B_PRId32 ") *** BFS superblock found at: %" + B_PRIdOFF "\n", superBlocks.CountItems() + 1, offset); dump_super_block(super); // add a copy of the superblock to the list @@ -302,9 +309,10 @@ Disk::ScanForSuperBlock(off_t start, off_t stop) for (int32 i = 0; i < superBlocks.CountItems(); i++) { bfs_disk_info *info = (bfs_disk_info *)superBlocks.ItemAt(i); - printf("%ld) %s, offset %Ld, size %g GB (%svalid)\n", i + 1, - info->super_block.name, info->offset, - 1.0 * info->super_block.num_blocks * info->super_block.block_size / (1024*1024*1024), + printf("%" B_PRId32 ") %s, offset %" B_PRIdOFF ", size %g GB (%svalid)" + "\n", i + 1, info->super_block.name, info->offset, + 1.0 * info->super_block.num_blocks * info->super_block.block_size + / (1024*1024*1024), ValidateSuperBlock(info->super_block) < B_OK ? "in" : ""); } @@ -375,7 +383,7 @@ Disk::ValidateSuperBlock() status_t Disk::RecreateSuperBlock() { - memset(&fSuperBlock,0,sizeof(disk_super_block)); + memset(&fSuperBlock, 0, sizeof(disk_super_block)); puts("\n*** Determine block size"); @@ -383,7 +391,7 @@ Disk::RecreateSuperBlock() if (status < B_OK) return status; - printf("\tblock size = %ld\n",BlockSize()); + printf("\tblock size = %" B_PRId32 "\n", BlockSize()); strcpy(fSuperBlock.name,"recovered"); fSuperBlock.magic1 = SUPER_BLOCK_MAGIC1; @@ -450,7 +458,7 @@ Disk::RecreateSuperBlock() if (fLogStart != ((indexDir.inode_num.allocation_group << fSuperBlock.ag_shift) + indexDir.inode_num.start - LogSize())) { fprintf(stderr,"ERROR: start of logging area doesn't fit assumed value " - "(%Ld blocks before indices)!\n", LogSize()); + "(%" B_PRIdOFF " blocks before indices)!\n", LogSize()); //gErrors++; } @@ -492,8 +500,8 @@ Disk::DetermineBlockSize() // read a quarter of the drive at maximum for (; offset < (fSize >> 2); offset += 1024) { if (fBufferedFile->ReadAt(offset, buffer, sizeof(buffer)) < B_OK) { - fprintf(stderr, "could not read from device (offset = %Ld, " - "size = %ld)!\n", offset, sizeof(buffer)); + fprintf(stderr, "could not read from device (offset = %" B_PRIdOFF + ", size = %ld)!\n", offset, sizeof(buffer)); status = B_IO_ERROR; break; } @@ -551,7 +559,8 @@ Disk::GetNextSpecialInode(char *buffer, off_t *_offset, off_t end, for (; offset < end; offset += BlockSize()) { if (fBufferedFile->ReadAt(offset, buffer, 1024) < B_OK) { - fprintf(stderr,"could not read from device (offset = %Ld, size = %d)!\n",offset,1024); + fprintf(stderr,"could not read from device (offset = %" B_PRIdOFF + ", size = %d)!\n", offset, 1024); *_offset = offset; return B_IO_ERROR; } @@ -576,7 +585,7 @@ Disk::GetNextSpecialInode(char *buffer, off_t *_offset, off_t end, // is the inode a special root inode (parent == self)? if (!memcmp(&inode->parent, &inode->inode_num, sizeof(inode_addr))) { - printf("\t special inode found at %Ld\n", offset); + printf("\t special inode found at %" B_PRIdOFF "\n", offset); *_offset = offset; return B_OK; @@ -596,10 +605,12 @@ Disk::SaveInode(bfs_inode *inode, bool *indices, bfs_inode *indexDir, printf("\troot node found!\n"); if (inode->inode_num.allocation_group != 8 || inode->inode_num.start != 0 - || inode->inode_num.length != 1) - printf("WARNING: root node has unexpected position: (ag = %ld, " - "start = %d, length = %d)\n", inode->inode_num.allocation_group, + || inode->inode_num.length != 1) { + printf("WARNING: root node has unexpected position: (ag = %" + B_PRId32 ", start = %d, length = %d)\n", + inode->inode_num.allocation_group, inode->inode_num.start, inode->inode_num.length); + } if (rootDir) memcpy(rootDir, inode, sizeof(bfs_inode)); } else if (inode->mode & S_INDEX_DIR) { @@ -662,7 +673,8 @@ Disk::ScanForIndexAndRoot(bfs_inode *indexDir,bfs_inode *rootDir) { SaveInode(inode,&indices,indexDir,&root,rootDir); - printf("root node at: 0x%Lx (DiskProbe)\n",logOffset / 512); + printf("root node at: 0x%" B_PRIxOFF " (DiskProbe)\n", + logOffset / 512); //fBufferedFile->ReadAt(logOffset + BlockSize(),buffer,1024); //if (*(uint32 *)buffer == BPLUSTREE_MAGIC) //{ diff --git a/src/bin/bfs_tools/lib/Inode.cpp b/src/bin/bfs_tools/lib/Inode.cpp index 4fab2fd..f13b615 100644 --- a/src/bin/bfs_tools/lib/Inode.cpp +++ b/src/bin/bfs_tools/lib/Inode.cpp @@ -276,17 +276,18 @@ Inode::SetName(const char *name) int32 oldLength = nameData == NULL ? 0 : nameData->data_size; int32 newLength = strlen(name) + (nameData == NULL ? sizeof(small_data) + 5 : 0); - if (int32(data) + newLength - oldLength >= (int32)(fInode + fDisk->BlockSize())) + if ((addr_t)data + newLength - oldLength >= (addr_t)(fInode + + fDisk->BlockSize())) return B_NO_MEMORY; if (nameData == NULL) { memmove(newLength + (uint8 *)fInode->small_data_start, fInode->small_data_start, - int32(data) - int32(fInode->small_data_start)); + (addr_t)data - (addr_t)fInode->small_data_start); nameData = fInode->small_data_start; } else { memmove(newLength + (uint8 *)nameData, nameData, - int32(data) - int32(fInode->small_data_start)); + (addr_t)data - (addr_t)fInode->small_data_start); } memset(nameData, 0, sizeof(small_data) + 5 + strlen(name)); @@ -766,7 +767,7 @@ DataStream::ReadAt(off_t pos, void *buffer, size_t size) //printf("DataStream::ReadAt(pos = %Ld,buffer = %p,size = %ld);\n",pos,buffer,size); // truncate size to read - if (pos + size > fInode->data.size) { + if (pos + (off_t)size > fInode->data.size) { if (pos > fInode->data.size) // reading outside the file return B_ERROR; @@ -782,14 +783,14 @@ DataStream::ReadAt(off_t pos, void *buffer, size_t size) if (status < B_OK) return status; - ssize_t bytes = min_c(size, fRunBlockEnd - pos); + ssize_t bytes = min_c((off_t)size, fRunBlockEnd - pos); //printf("### read %ld bytes from %Ld\n### --\n",bytes,fDisk->ToOffset(fRun) + pos - fRunFileOffset); bytes = fDisk->ReadAt(fDisk->ToOffset(fRun) + pos - fRunFileOffset, buffer, bytes); if (bytes <= 0) { if (bytes == 0) { - printf("could not read bytes at: %ld,%d\n", + printf("could not read bytes at: %" B_PRId32 ",%d\n", fRun.allocation_group, fRun.start); } return bytes < 0 ? bytes : B_BAD_DATA; @@ -813,7 +814,7 @@ DataStream::WriteAt(off_t pos, const void *buffer, size_t size) NodeGetter _(this); // FIXME: truncate size -> should enlargen the file - if (pos + size > fInode->data.size) { + if (pos + (off_t)size > fInode->data.size) { if (pos > fInode->data.size) // writing outside the file return B_ERROR; @@ -829,7 +830,7 @@ DataStream::WriteAt(off_t pos, const void *buffer, size_t size) if (status < B_OK) return status; - ssize_t bytes = min_c(size,fRunBlockEnd - pos); + ssize_t bytes = min_c((off_t)size, fRunBlockEnd - pos); //printf("### write %ld bytes to %Ld\n### --\n",bytes,fDisk->ToOffset(fRun) + pos - fRunFileOffset); bytes = fDisk->WriteAt(fDisk->ToOffset(fRun) + pos - fRunFileOffset,buffer,bytes); @@ -959,8 +960,8 @@ File::CopyTo(const char *root, bool fullPath, Inode::Source *source) << (int32)BlockRun().start; path.Append(sub.String()); } - printf("%ld,%d -> %s\n", BlockRun().allocation_group, BlockRun().start, - path.Path()); + printf("%" B_PRId32 ",%d -> %s\n", BlockRun().allocation_group, + BlockRun().start, path.Path()); BFile file; status = file.SetTo(path.Path(), diff --git a/src/bin/bfs_tools/lib/bfs.h b/src/bin/bfs_tools/lib/bfs.h index f2ac852..224e3a0 100644 --- a/src/bin/bfs_tools/lib/bfs.h +++ b/src/bin/bfs_tools/lib/bfs.h @@ -251,7 +251,7 @@ inline small_data *small_data::Next() inline bool small_data::IsLast(bfs_inode *inode) { - return (uint32)this > (uint32)inode + inode->inode_size - sizeof(small_data) + return (addr_t)this > (addr_t)inode + inode->inode_size - sizeof(small_data) || name_size == 0; } diff --git a/src/bin/bfs_tools/lib/dump.cpp b/src/bin/bfs_tools/lib/dump.cpp index 651eeda..caaf851 100644 --- a/src/bin/bfs_tools/lib/dump.cpp +++ b/src/bin/bfs_tools/lib/dump.cpp @@ -38,7 +38,7 @@ get_tupel(uint32 id) void dump_block_run(const char *prefix, const block_run &run, const char *postfix) { - Print("%s(%ld, %d, %d)%s\n", prefix, run.allocation_group, + Print("%s(%" B_PRId32 ", %d, %d)%s\n", prefix, run.allocation_group, run.start, run.length, postfix); } @@ -48,29 +48,29 @@ dump_super_block(const disk_super_block *superBlock) { Print("disk_super_block:\n"); Print(" name = %s\n", superBlock->name); - Print(" magic1 = %#08lx (%s) %s\n", superBlock->magic1, + Print(" magic1 = %#08" B_PRIx32 " (%s) %s\n", superBlock->magic1, get_tupel(superBlock->magic1), superBlock->magic1 == SUPER_BLOCK_MAGIC1 ? "valid" : "INVALID"); - Print(" fs_byte_order = %#08lx (%s, %s endian)\n", + Print(" fs_byte_order = %#08" B_PRIx32 " (%s, %s endian)\n", superBlock->fs_byte_order, get_tupel(superBlock->fs_byte_order), superBlock->fs_byte_order == SUPER_BLOCK_FS_LENDIAN ? "little" : "big"); - Print(" block_size = %lu\n", superBlock->block_size); - Print(" block_shift = %lu\n", superBlock->block_shift); - Print(" num_blocks = %Lu\n", superBlock->num_blocks); - Print(" used_blocks = %Lu\n", superBlock->used_blocks); - Print(" inode_size = %lu\n", superBlock->inode_size); - Print(" magic2 = %#08lx (%s) %s\n", superBlock->magic2, + Print(" block_size = %" B_PRIu32 "\n", superBlock->block_size); + Print(" block_shift = %" B_PRIu32 "\n", superBlock->block_shift); + Print(" num_blocks = %" B_PRIdOFF "\n", superBlock->num_blocks); + Print(" used_blocks = %" B_PRIdOFF "\n", superBlock->used_blocks); + Print(" inode_size = %" B_PRId32 "\n", superBlock->inode_size); + Print(" magic2 = %#08" B_PRIx32 " (%s) %s\n", superBlock->magic2, get_tupel(superBlock->magic2), superBlock->magic2 == (int)SUPER_BLOCK_MAGIC2 ? "valid" : "INVALID"); - Print(" blocks_per_ag = %lu\n", superBlock->blocks_per_ag); - Print(" ag_shift = %lu\n", superBlock->ag_shift); - Print(" num_ags = %lu\n", superBlock->num_ags); - Print(" flags = %#08lx (%s)\n", superBlock->flags, + Print(" blocks_per_ag = %" B_PRId32 "\n", superBlock->blocks_per_ag); + Print(" ag_shift = %" B_PRId32 "\n", superBlock->ag_shift); + Print(" num_ags = %" B_PRId32 "\n", superBlock->num_ags); + Print(" flags = %#08" B_PRIx32 " (%s)\n", superBlock->flags, get_tupel(superBlock->flags)); dump_block_run(" log_blocks = ", superBlock->log_blocks); - Print(" log_start = %Lu\n", superBlock->log_start); - Print(" log_end = %Lu\n", superBlock->log_end); - Print(" magic3 = %#08lx (%s) %s\n", superBlock->magic3, + Print(" log_start = %" B_PRIdOFF "\n", superBlock->log_start); + Print(" log_end = %" B_PRIdOFF "\n", superBlock->log_end); + Print(" magic3 = %#08" B_PRIx32 " (%s) %s\n", superBlock->magic3, get_tupel(superBlock->magic3), superBlock->magic3 == SUPER_BLOCK_MAGIC3 ? "valid" : "INVALID"); dump_block_run(" root_dir = ", superBlock->root_dir); @@ -91,7 +91,7 @@ dump_data_stream(const bfs_inode *inode, const data_stream *stream, bool showOff char buffer[256]; if (showOffsets) - snprintf(buffer, sizeof(buffer), " %16lld", offset); + snprintf(buffer, sizeof(buffer), " %16" B_PRIdOFF, offset); else buffer[0] = '\0'; @@ -100,21 +100,23 @@ dump_data_stream(const bfs_inode *inode, const data_stream *stream, bool showOff offset += stream->direct[i].length * inode->inode_size; } } - Print(" max_direct_range = %Lu\n", stream->max_direct_range); + Print(" max_direct_range = %" B_PRIdOFF "\n", + stream->max_direct_range); if (!stream->indirect.IsZero()) dump_block_run(" indirect = ", stream->indirect); - Print(" max_indirect_range = %Lu\n", stream->max_indirect_range); + Print(" max_indirect_range = %" B_PRIdOFF "\n", + stream->max_indirect_range); if (!stream->double_indirect.IsZero()) { dump_block_run(" double_indirect = ", stream->double_indirect); } - Print(" max_double_indirect_range = %Lu\n", + Print(" max_double_indirect_range = %" B_PRIdOFF "\n", stream->max_double_indirect_range); - Print(" size = %Lu\n", stream->size); + Print(" size = %" B_PRIdOFF "\n", stream->size); } @@ -126,13 +128,14 @@ dump_inode(const Inode *nameNode, const bfs_inode *inode, bool showOffsets) else Print("inode:\n"); - Print(" magic1 = %08lx (%s) %s\n",inode->magic1, - get_tupel(inode->magic1), (inode->magic1 == INODE_MAGIC1 ? "valid" : "INVALID")); + Print(" magic1 = %08" B_PRIx32 " (%s) %s\n",inode->magic1, + get_tupel(inode->magic1), + (inode->magic1 == INODE_MAGIC1 ? "valid" : "INVALID")); dump_block_run( " inode_num = ",inode->inode_num); - Print(" uid = %lu\n",inode->uid); - Print(" gid = %lu\n",inode->gid); - Print(" mode = %10lo (octal)\n",inode->mode); - Print(" flags = %08lx\n",inode->flags); + Print(" uid = %" B_PRIu32 "\n",inode->uid); + Print(" gid = %" B_PRIu32 "\n",inode->gid); + Print(" mode = %10" B_PRIo32 " (octal)\n",inode->mode); + Print(" flags = %08" B_PRIx32 "\n",inode->flags); time_t time; time = (time_t)(inode->create_time >> 16); @@ -142,9 +145,9 @@ dump_inode(const Inode *nameNode, const bfs_inode *inode, bool showOffsets) dump_block_run( " parent = ",inode->parent); dump_block_run( " attributes = ",inode->attributes); - Print(" type = %lu\n",inode->type); - Print(" inode_size = %lu\n",inode->inode_size); - Print(" etc = %#08lx\n",inode->etc); + Print(" type = %" B_PRIu32 "\n",inode->type); + Print(" inode_size = %" B_PRId32 "\n",inode->inode_size); + Print(" etc = %#08" B_PRIx32 "\n",inode->etc); Print(" short_symlink = %s\n", S_ISLNK(inode->mode) && (inode->flags & INODE_LONG_SYMLINK) == 0 ? inode->short_symlink : "-"); @@ -172,7 +175,8 @@ dump_small_data(Inode *inode) inode->InodeBuffer()->inode_size - sizeof(struct bfs_inode)); while (inode->GetNextSmallData(&item) == B_OK) { - printf("%#08lx (%s), name = \"%s\", ", item->type, get_tupel(item->type), item->Name()); + printf("%#08" B_PRIx32 " (%s), name = \"%s\", ", item->type, + get_tupel(item->type), item->Name()); if (item->type == FILE_NAME_TYPE || item->type == B_STRING_TYPE || item->type == B_MIME_STRING_TYPE) @@ -187,15 +191,19 @@ void dump_bplustree_header(const bplustree_header* header) { printf("bplustree_header:\n"); - printf(" magic = %#08lx (%s) %s\n", header->magic, - get_tupel(header->magic), + printf(" magic = %#08" B_PRIx32 " (%s) %s\n", + header->magic, get_tupel(header->magic), header->magic == BPLUSTREE_MAGIC ? "valid" : "INVALID"); - printf(" node_size = %lu\n", header->node_size); - printf(" max_number_of_levels = %lu\n", header->max_number_of_levels); - printf(" data_type = %lu\n", header->data_type); - printf(" root_node_pointer = %Ld\n", header->root_node_pointer); - printf(" free_node_pointer = %Ld\n", header->free_node_pointer); - printf(" maximum_size = %Lu\n", header->maximum_size); + printf(" node_size = %" B_PRIu32 "\n", header->node_size); + printf(" max_number_of_levels = %" B_PRIu32 "\n", + header->max_number_of_levels); + printf(" data_type = %" B_PRIu32 "\n", header->data_type); + printf(" root_node_pointer = %" B_PRIdOFF "\n", + header->root_node_pointer); + printf(" free_node_pointer = %" B_PRIdOFF "\n", + header->free_node_pointer); + printf(" maximum_size = %" B_PRIdOFF "\n", + header->maximum_size); } @@ -205,9 +213,9 @@ dump_bplustree_node(const bplustree_node* node, const bplustree_header* header, { Print("bplustree_node (%s node):\n", node->overflow_link == BPLUSTREE_NULL ? "leaf" : "index"); - Print(" left_link = %Ld\n", node->left_link); - Print(" right_link = %Ld\n", node->right_link); - Print(" overflow_link = %Ld\n", node->overflow_link); + Print(" left_link = %" B_PRIdOFF "\n", node->left_link); + Print(" right_link = %" B_PRIdOFF "\n", node->right_link); + Print(" overflow_link = %" B_PRIdOFF "\n", node->overflow_link); Print(" all_key_count = %u\n", node->all_key_count); Print(" all_key_length = %u\n", node->all_key_length); @@ -226,7 +234,7 @@ dump_bplustree_node(const bplustree_node* node, const bplustree_header* header, uint16 length; char* key = (char *)node->KeyAt(i, &length); if (length > 255) { - Print(" %2ld. Invalid length (%u)!!\n", i, length); + Print(" %2" B_PRId32 ". Invalid length (%u)!!\n", i, length); dump_block((char *)node, header->node_size, sizeof(off_t)); break; } @@ -236,33 +244,35 @@ dump_bplustree_node(const bplustree_node* node, const bplustree_header* header, buffer[length] = '\0'; off_t *value = node->Values() + i; - if ((uint32)value < (uint32)node || (uint32)value > (uint32)node + header->node_size) - Print(" %2ld. Invalid Offset!!\n",i); - else { - Print(" %2ld. ",i); + if ((addr_t)value < (addr_t)node + || (addr_t)value > (addr_t)node + header->node_size) { + Print(" %2" B_PRId32 ". Invalid Offset!!\n", i); + } else { + Print(" %2" B_PRId32 ". ",i); if (header->data_type == BPLUSTREE_STRING_TYPE) Print("\"%s\"",buffer); else if (header->data_type == BPLUSTREE_INT32_TYPE) { - Print("int32 = %ld (0x%lx)", *(int32 *)&buffer, - *(int32 *)&buffer); + Print("int32 = %" B_PRId32 " (0x%" B_PRIx32 ")", + *(int32 *)&buffer, *(int32 *)&buffer); } else if (header->data_type == BPLUSTREE_UINT32_TYPE) { - Print("uint32 = %lu (0x%lx)", *(uint32 *)&buffer, - *(uint32 *)&buffer); + Print("uint32 = %" B_PRIu32 " (0x%" B_PRIx32 ")", + *(uint32 *)&buffer, *(uint32 *)&buffer); } else if (header->data_type == BPLUSTREE_INT64_TYPE) { - Print("int64 = %Ld (0x%Lx)", *(int64 *)&buffer, - *(int64 *)&buffer); + Print("int64 = %" B_PRId64 " (0x%" B_PRIx64 ")", + *(int64 *)&buffer, *(int64 *)&buffer); } else Print("???"); off_t offset = *value & 0x3fffffffffffffffLL; - Print(" (%d bytes) -> %Ld",length,offset); + Print(" (%d bytes) -> %" B_PRIdOFF,length,offset); if (disk != NULL) { block_run run = disk->ToBlockRun(offset); - Print(" (%ld, %d)", run.allocation_group, run.start); + Print(" (%" B_PRId32 ", %d)", run.allocation_group, run.start); } if (bplustree_node::LinkType(*value) == BPLUSTREE_DUPLICATE_FRAGMENT) { - Print(" (duplicate fragment %Ld)\n", *value & 0x3ff); + Print(" (duplicate fragment %" B_PRIdOFF ")\n", + *value & 0x3ff); } else if (bplustree_node::LinkType(*value) == BPLUSTREE_DUPLICATE_NODE) { Print(" (duplicate node)\n"); @@ -310,7 +320,7 @@ dump_block(const char *buffer, uint32 size, int8 valueSize) for (uint32 offset = start; offset < start + kBlockSize; offset += valueSize) { if (valueSize == sizeof(off_t)) - Print("%s%Ld", offset == start ? "" : ", ", + Print("%s%" B_PRIdOFF, offset == start ? "" : ", ", *(off_t *)(buffer + offset)); } Print(")"); ############################################################################ Commit: aff59d31a3dd3b6755347f5784c8e8cb57aee260 URL: http://cgit.haiku-os.org/haiku/commit/?id=aff59d3 Author: Jérôme Duval <jerome.duval@xxxxxxxxx> Date: Fri May 10 17:42:24 2013 UTC hey: fixes 64 bit warnings ---------------------------------------------------------------------------- diff --git a/src/bin/hey.cpp b/src/bin/hey.cpp index b311ea3..ac464be 100644 --- a/src/bin/hey.cpp +++ b/src/bin/hey.cpp @@ -164,11 +164,16 @@ parse(BMessenger& the_application, int argc, char *argv[], int32 argapp) } else { if (the_reply.what == (uint32)B_MESSAGE_NOT_UNDERSTOOD || the_reply.what==(uint32)B_ERROR){ // I do it myself if (the_reply.HasString("message")){ - if (!silent) - printf("%s (error 0x%8lX)\n", the_reply.FindString("message"), the_reply.FindInt32("error")); + if (!silent) { + printf("%s (error 0x%8" B_PRIx32 ")\n", + the_reply.FindString("message"), + the_reply.FindInt32("error")); + } } else { - if (!silent) - printf("error 0x%8lX\n", the_reply.FindInt32("error")); + if (!silent) { + printf("error 0x%8" B_PRIx32 "\n", + the_reply.FindInt32("error")); + } } return 1; } else { @@ -187,7 +192,7 @@ parse(BMessenger& the_application, int argc, char *argv[], int32 argapp) } else if(tc==B_INT32_TYPE){ int32 v; the_reply.FindInt32("result", &v); - printf("%ld\n", v); + printf("%" B_PRId32 "\n", v); } else if(tc==B_UINT8_TYPE){ uint8 v; the_reply.FindInt8("result", (int8*)&v); @@ -199,7 +204,7 @@ parse(BMessenger& the_application, int argc, char *argv[], int32 argapp) } else if(tc==B_UINT32_TYPE){ uint32 v; the_reply.FindInt32("result", (int32*)&v); - printf("%lu\n", v); + printf("%" B_PRIu32 "\n", v); } else if(tc==B_STRING_TYPE){ const char* v; the_reply.FindString("result", &v); @@ -288,8 +293,8 @@ main(int argc, char *argv[]) be_roster->GetAppList(&team_list); - for (int32 i=0; i<team_list.CountItems(); i++){ - teamid = (team_id)team_list.ItemAt(i); + for (int32 i = 0; i < team_list.CountItems(); i++){ + teamid = (team_id)(addr_t)team_list.ItemAt(i); be_roster->GetRunningAppInfo(teamid, &appinfo); if (strcmp(appinfo.signature, argv[argapp])==0){ the_application=BMessenger(appinfo.signature); @@ -479,7 +484,7 @@ Hey(BMessenger* target, char* argv[], int32* argx, int32 argc, BMessage* reply) // if all goes well, rply contains all kinds of property infos int32 j=0; void *voidptr; - int32 sizefound; + ssize_t sizefound; BPropertyInfo propinfo; const value_info *vinfo; int32 vinfo_index, vinfo_count; @@ -958,8 +963,9 @@ void add_message_contents(BList *textlist, BMessage *msg, int32 level) { int32 count; - int32 i, sizefound, j; - ulong typefound; + int32 i, j; + type_code typefound; + ssize_t sizefound; #ifdef HAIKU_TARGET_PLATFORM_DANO const char *namefound; #else @@ -1178,14 +1184,15 @@ format_data(int32 type, char *ptr, long size) case B_INT64_TYPE: str = new char[64]; i64 = *(int64*)ptr; - sprintf(str, "%Ld (0x%LX)", i64, i64); + sprintf(str, "%" B_PRId64 " (0x%" B_PRIx64 ")", i64, i64); break; case B_SIZE_T_TYPE: case B_INT32_TYPE: str = new char[64]; i32 = *(int32*)ptr; - sprintf(str, "%ld (0x%08lX)", i32, i32); + sprintf(str, "%" B_PRId32 " (0x%08" B_PRId32 ")", i32, + i32); break; case B_INT16_TYPE: @@ -1204,13 +1211,15 @@ format_data(int32 type, char *ptr, long size) case B_UINT64_TYPE: str = new char[64]; ui64 = *(uint64*)ptr; - sprintf(str, "%Lu (0x%LX)", ui64, ui64); + sprintf(str, "%" B_PRIu64 " (0x%" B_PRIx64 ")", ui64, + ui64); break; case B_UINT32_TYPE: str = new char[64]; ui32 = *(uint32*)ptr; - sprintf(str, "%lu (0x%08lX)", ui32, ui32); + sprintf(str, "%" B_PRIu32 " (0x%08" B_PRIx32 ")", ui32, + ui32); break; case B_UINT16_TYPE: @@ -1394,7 +1403,8 @@ format_data(int32 type, char *ptr, long size) strcat(str, vinfo[vinfo_index].name); strcat(str, " "); - sprintf(str+strlen(str), "0x%8lX (", vinfo[vinfo_index].value); + sprintf(str+strlen(str), "0x%8" B_PRIx32 " (", + vinfo[vinfo_index].value); id_to_string(vinfo[vinfo_index].value, str+strlen(str)); strcat(str, ")"); ############################################################################ Commit: 7074a7c7ecd40a68786110fc7d3f6d6d83bda693 URL: http://cgit.haiku-os.org/haiku/commit/?id=7074a7c Author: Jérôme Duval <jerome.duval@xxxxxxxxx> Date: Fri May 10 17:44:51 2013 UTC reindex: fixes 64 bit warnings ---------------------------------------------------------------------------- diff --git a/src/bin/reindex.cpp b/src/bin/reindex.cpp index 090fa74..319e605 100644 --- a/src/bin/reindex.cpp +++ b/src/bin/reindex.cpp @@ -247,7 +247,7 @@ handleFile(BEntry *entry, BNode *node) } // rewrite attrs and empty the list - while ((attr = static_cast<Attribute *>(list.RemoveItem(0L))) != NULL) { + while ((attr = static_cast<Attribute *>(list.RemoveItem((int32)0))) != NULL) { // write attribute back to file status = attr->WriteToFile(node); if (status != B_OK) { @@ -294,8 +294,8 @@ copyIndicesFromVolume(const char *path, BEntry &to) if (fs_create_index(targetDevice, index->d_name, indexInfo.type, 0) == -1 && errno != B_FILE_EXISTS && errno != B_BAD_VALUE) { - fprintf(stderr, "Could not create index '%s' (type = %lu): %s\n", - index->d_name, indexInfo.type, strerror(errno)); + fprintf(stderr, "Could not create index '%s' (type = %" B_PRIu32 + "): %s\n", index->d_name, indexInfo.type, strerror(errno)); } else gAttrList.AddItem(strdup(index->d_name)); } ############################################################################ Commit: 0059a07ade67dfac4d8de0cbdd11502958ee8faf URL: http://cgit.haiku-os.org/haiku/commit/?id=0059a07 Author: Jérôme Duval <jerome.duval@xxxxxxxxx> Date: Fri May 10 17:46:29 2013 UTC roster: fixes 64 bit warnings ---------------------------------------------------------------------------- diff --git a/src/bin/roster.cpp b/src/bin/roster.cpp index ae611b3..9eca23b 100644 --- a/src/bin/roster.cpp +++ b/src/bin/roster.cpp @@ -79,7 +79,7 @@ output_team(team_id id, int32 mode) if ((mode & kNoTruncateMode) == 0) truncate_string(name, kNameFieldWidth); - printf("%6ld %*s %5ld %5lx (%s)\n", + printf("%6" B_PRId32 " %*s %5" B_PRId32 " %5" B_PRIx32 " (%s)\n", id, (int)kNameFieldWidth, name.String(), info.port, info.flags, info.signature); } @@ -141,7 +141,7 @@ main(int argc, char **argv) // Iterate through the list. for (int32 i = 0; i < applicationList.CountItems(); i++) - output_team((team_id)applicationList.ItemAt(i), mode); + output_team((team_id)(addr_t)applicationList.ItemAt(i), mode); return 0; } ############################################################################ Revision: hrev45657 Commit: bc8c7d615d95fbca5192912189c934510ee72a92 URL: http://cgit.haiku-os.org/haiku/commit/?id=bc8c7d6 Author: Jérôme Duval <jerome.duval@xxxxxxxxx> Date: Fri May 10 17:49:36 2013 UTC translate: fixes 64 bit warnings ---------------------------------------------------------------------------- diff --git a/src/bin/translate.cpp b/src/bin/translate.cpp index 2796991..48de395 100644 --- a/src/bin/translate.cpp +++ b/src/bin/translate.cpp @@ -131,21 +131,21 @@ print_translation_format(const translation_format &format) void TypeList::Add(uint32 type) { - fList.AddItem((void *)type, 0); + fList.AddItem((void *)(addr_t)type, 0); } bool TypeList::Remove(uint32 type) { - return fList.RemoveItem((void *)type); + return fList.RemoveItem((void *)(addr_t)type); } bool TypeList::FindType(uint32 type) { - return fList.IndexOf((void *)type) >= 0; + return fList.IndexOf((void *)(addr_t)type) >= 0; } @@ -155,7 +155,7 @@ TypeList::SetTo(TypeList &types) fList.MakeEmpty(); for (int32 i = 0; i < types.Count(); i++) - fList.AddItem((void *)types.TypeAt(i)); + fList.AddItem((void *)(addr_t)types.TypeAt(i)); } @@ -169,7 +169,7 @@ TypeList::Count() uint32 TypeList::TypeAt(int32 index) { - return (uint32)fList.ItemAt(index); + return (uint32)(addr_t)fList.ItemAt(index); } @@ -612,7 +612,8 @@ TranslateApp::ListTranslators(uint32 type) continue; } - printf("name: %s\ninfo: %s\nversion: %ld.%ld.%ld\n", name, info, + printf("name: %s\ninfo: %s\nversion: %" B_PRId32 ".%" B_PRId32 ".%" + B_PRId32 "\n", name, info, B_TRANSLATION_MAJOR_VERSION(version), B_TRANSLATION_MINOR_VERSION(version), B_TRANSLATION_REVISION_VERSION(version));