Compilation and 64-bit fixes to libbe.so sources.

Fixed the usual issues - printf format strings, uint32 instead of
addr_t, etc. One thing that isn't so nice is several places where
BList is used to store (u)int32, these require a double cast to addr_t
then void* to silence a warning on x86_64.
This commit is contained in:
Alex Smith
2012-07-30 21:27:21 +01:00
parent ef67788fba
commit 9be774b553
28 changed files with 74 additions and 66 deletions
+1 -1
View File
@@ -411,7 +411,7 @@ private:
void _ShowContextMenu(BPoint where);
void _FilterDisallowedChars(char* text,
int32& length, text_run_array* runArray);
ssize_t& length, text_run_array* runArray);
private:
BPrivate::TextGapBuffer* fText;
+1 -1
View File
@@ -522,7 +522,7 @@ BApplication::Quit()
if (!name)
name = "no-name";
printf("ERROR - you must Lock the application object before calling "
"Quit(), team=%ld, looper=%s\n", Team(), name);
"Quit(), team=%" B_PRId32 ", looper=%s\n", Team(), name);
unlock = true;
if (!Lock())
return;
+4 -3
View File
@@ -443,7 +443,8 @@ BLooper::Quit()
if (!IsLocked()) {
printf("ERROR - you must Lock a looper before calling Quit(), "
"team=%ld, looper=%s\n", Team(), Name() ? Name() : "unnamed");
"team=%" B_PRId32 ", looper=%s\n", Team(),
Name() ? Name() : "unnamed");
}
// Try to lock
@@ -547,7 +548,7 @@ BLooper::IsLocked() const
}
uint32 stack;
return ((uint32)&stack & ~(B_PAGE_SIZE - 1)) == fCachedStack
return ((addr_t)&stack & ~(B_PAGE_SIZE - 1)) == fCachedStack
|| find_thread(NULL) == fOwner;
}
@@ -1338,7 +1339,7 @@ BLooper::check_lock()
// It is used in situations where it's clear that the looper is valid,
// ie. from handlers
uint32 stack;
if (((uint32)&stack & ~(B_PAGE_SIZE - 1)) == fCachedStack
if (((addr_t)&stack & ~(B_PAGE_SIZE - 1)) == fCachedStack
|| fOwner == find_thread(NULL))
return;
+1 -1
View File
@@ -426,7 +426,7 @@ BPropertyInfo::PrintToStream() const
// specifiers
for (int32 i = 0; i < 10 && fPropInfo[pi].specifiers[i] != 0; i++) {
uint32 spec = fPropInfo[pi].specifiers[i];
printf("%lu", spec);
printf("%" B_PRIu32, spec);
}
printf("\n");
}
+2 -2
View File
@@ -657,7 +657,7 @@ BRoster::GetAppList(BList* teamIDList) const
if (reply.what == B_REG_SUCCESS) {
team_id team;
for (int32 i = 0; reply.FindInt32("teams", i, &team) == B_OK; i++)
teamIDList->AddItem((void*)team);
teamIDList->AddItem((void*)(addr_t)team);
} else {
if (reply.FindInt32("error", &error) != B_OK)
error = B_ERROR;
@@ -700,7 +700,7 @@ BRoster::GetAppList(const char* sig, BList* teamIDList) const
if (reply.what == B_REG_SUCCESS) {
team_id team;
for (int32 i = 0; reply.FindInt32("teams", i, &team) == B_OK; i++)
teamIDList->AddItem((void*)team);
teamIDList->AddItem((void*)(addr_t)team);
} else if (reply.FindInt32("error", &error) != B_OK)
error = B_ERROR;
}
+1 -1
View File
@@ -697,7 +697,7 @@ BAlert::_CreateButton(int32 which, const char* label)
rect.bottom = rect.top;
char name[32];
snprintf(name, sizeof(name), "_b%ld_", which);
snprintf(name, sizeof(name), "_b%" B_PRId32 "_", which);
BButton* button = new(std::nothrow) BButton(rect, name, label, message,
B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
+2 -1
View File
@@ -839,7 +839,8 @@ BChannelSlider::_DrawThumbs()
// draw some kind of current value tool tip
if (fCurrentChannel != -1 && fMinPoint != 0) {
char valueString[32];
snprintf(valueString, 32, "%ld", ValueFor(fCurrentChannel));
snprintf(valueString, 32, "%" B_PRId32,
ValueFor(fCurrentChannel));
float stringWidth = fBackingView->StringWidth(valueString);
float width = max_c(10.0, stringWidth);
BRect valueRect(0.0, 0.0, width, 10.0);
+3 -3
View File
@@ -68,9 +68,9 @@ public:
// TODO: make this work with Unicode characters!
bool HasTrigger(uint32 c)
{ return fList.HasItem((void*)tolower(c)); }
{ return fList.HasItem((void*)(addr_t)tolower(c)); }
bool AddTrigger(uint32 c)
{ return fList.AddItem((void*)tolower(c)); }
{ return fList.AddItem((void*)(addr_t)tolower(c)); }
private:
BList fList;
@@ -2883,7 +2883,7 @@ bool
BMenu::_OkToProceed(BMenuItem* item, bool keyDown)
{
BPoint where;
ulong buttons;
uint32 buttons;
GetMouse(&where, &buttons, false);
bool stickyMode = _IsStickyMode();
// Quit if user clicks the mouse button in sticky mode
+4 -3
View File
@@ -157,15 +157,16 @@ BPolygon::_AddPoints(const BPoint* points, int32 count, bool computeBounds)
if (points == NULL || count <= 0)
return false;
if (count > MAX_POINT_COUNT || (fCount + count) > MAX_POINT_COUNT) {
fprintf(stderr, "BPolygon::_AddPoints(%ld) - too many points\n",
count);
fprintf(stderr, "BPolygon::_AddPoints(%" B_PRId32 ") - too many points"
"\n", count);
return false;
}
BPoint* newPoints = (BPoint*)realloc(fPoints, (fCount + count)
* sizeof(BPoint));
if (newPoints == NULL) {
fprintf(stderr, "BPolygon::_AddPoints(%ld) out of memory\n", count);
fprintf(stderr, "BPolygon::_AddPoints(%" B_PRId32 ") out of memory\n",
count);
return false;
}
+1 -1
View File
@@ -575,7 +575,7 @@ BPrintJob::_RecurseView(BView* view, BPoint origin, BPicture* picture,
void
BPrintJob::_GetMangledName(char* buffer, size_t bufferSize) const
{
snprintf(buffer, bufferSize, "%s@%lld", fPrintJobName,
snprintf(buffer, bufferSize, "%s@%" B_PRId64, fPrintJobName,
system_time() / 1000);
}
+2 -2
View File
@@ -557,7 +557,7 @@ BShelf::~BShelf()
while (fReplicants.CountItems() > 0) {
replicant_data *data = (replicant_data *)fReplicants.ItemAt(0);
fReplicants.RemoveItem(0L);
fReplicants.RemoveItem((int32)0);
delete data;
}
}
@@ -1003,7 +1003,7 @@ BShelf::ReplicantAt(int32 index, BView **_view, uint32 *_uniqueID,
if (_view)
*_view = NULL;
if (_uniqueID)
*_uniqueID = ~0UL;
*_uniqueID = ~(uint32)0;
if (_error)
*_error = B_BAD_INDEX;
+7 -7
View File
@@ -731,7 +731,7 @@ BTextView::WindowActivated(bool state)
}
BPoint where;
ulong buttons;
uint32 buttons;
GetMouse(&where, &buttons, false);
if (Bounds().Contains(where))
@@ -3241,7 +3241,7 @@ BTextView::_InitObject(BRect textRect, const BFont *initialFont,
fSelectable = true;
fEditable = true;
fWrap = true;
fMaxBytes = LONG_MAX;
fMaxBytes = INT32_MAX;
fDisallowedChars = NULL;
fAlignment = B_ALIGN_LEFT;
fAutoindent = false;
@@ -5036,7 +5036,7 @@ BTextView::_Activate()
_ShowCaret();
BPoint where;
ulong buttons;
uint32 buttons;
GetMouse(&where, &buttons, false);
if (Bounds().Contains(where))
_TrackMouse(where, NULL);
@@ -5600,7 +5600,7 @@ BTextView::_ShowContextMenu(BPoint where)
void
BTextView::_FilterDisallowedChars(char* text, int32& length,
BTextView::_FilterDisallowedChars(char* text, ssize_t& length,
text_run_array* runArray)
{
if (!fDisallowedChars)
@@ -5609,9 +5609,9 @@ BTextView::_FilterDisallowedChars(char* text, int32& length,
if (fDisallowedChars->IsEmpty() || !text)
return;
int32 stringIndex = 0;
ssize_t stringIndex = 0;
if (runArray) {
int32 remNext = 0;
ssize_t remNext = 0;
for (int i = 0; i < runArray->count; i++) {
runArray->runs[i].offset -= remNext;
@@ -5669,7 +5669,7 @@ void
BTextView::TextTrackState::SimulateMouseMovement(BTextView *textView)
{
BPoint where;
ulong buttons;
uint32 buttons;
// When the mouse cursor is still and outside the textview,
// no B_MOUSE_MOVED message are sent, obviously. But scrolling
// has to work neverthless, so we "fake" a MouseMoved() call here.
+5 -5
View File
@@ -5882,8 +5882,8 @@ BView::_PrintToStream()
"\tNextSibling: %s\n"
"\tPrevSibling: %s\n"
"\tOwner(Window): %s\n"
"\tToken: %ld\n"
"\tFlags: %ld\n"
"\tToken: %" B_PRId32 "\n"
"\tFlags: %" B_PRId32 "\n"
"\tView origin: (%f,%f)\n"
"\tView Bounds rectangle: (%f,%f,%f,%f)\n"
"\tShow level: %d\n"
@@ -5893,8 +5893,8 @@ BView::_PrintToStream()
"\tHorizontal Scrollbar %s\n"
"\tIs Printing?: %s\n"
"\tShelf?: %s\n"
"\tEventMask: %ld\n"
"\tEventOptions: %ld\n",
"\tEventMask: %" B_PRId32 "\n"
"\tEventOptions: %" B_PRId32 "\n",
Name(),
fParent ? fParent->Name() : "NULL",
fFirstChild ? fFirstChild->Name() : "NULL",
@@ -5922,7 +5922,7 @@ BView::_PrintToStream()
"\t\tHighColor: [%d,%d,%d,%d]\n"
"\t\tLowColor: [%d,%d,%d,%d]\n"
"\t\tViewColor: [%d,%d,%d,%d]\n"
"\t\tPattern: %llx\n"
"\t\tPattern: %" B_PRIx64 "\n"
"\t\tDrawingMode: %d\n"
"\t\tLineJoinMode: %d\n"
"\t\tLineCapMode: %d\n"
+5 -4
View File
@@ -515,7 +515,7 @@ BWindow::Quit()
name = "no-name";
printf("ERROR - you must Lock a looper before calling Quit(), "
"team=%ld, looper=%s\n", Team(), name);
"team=%" B_PRId32 ", looper=%s\n", Team(), name);
}
// Try to lock
@@ -1032,7 +1032,8 @@ BWindow::DispatchMessage(BMessage* msg, BHandler* target)
be_roster->GetAppList(info.signature, &list);
for (int32 i = 0; i < list.CountItems(); i++) {
do_minimize_team(BRect(), (team_id)list.ItemAt(i), false);
do_minimize_team(BRect(), (team_id)(addr_t)list.ItemAt(i),
false);
}
break;
}
@@ -1433,8 +1434,8 @@ FrameMoved(origin);
if (BView* view = _FindView(info->token))
view->_Draw(info->updateRect);
else {
printf("_UPDATE_ - didn't find view by token: %ld\n",
info->token);
printf("_UPDATE_ - didn't find view by token: %"
B_PRId32 "\n", info->token);
}
//drawTime += system_time() - drawStart;
}
@@ -85,9 +85,12 @@ public:
void Dump()
{
printf("ComplexLayouter::MyLayoutInfo(): %ld elements:\n", fCount);
for (int32 i = 0; i < fCount + 1; i++)
printf(" %2ld: location: %4ld\n", i, fLocations[i]);
printf("ComplexLayouter::MyLayoutInfo(): %" B_PRId32 " elements:\n",
fCount);
for (int32 i = 0; i < fCount + 1; i++) {
printf(" %2" B_PRId32 ": location: %4" B_PRId32 "\n", i,
fLocations[i]);
}
}
public:
@@ -94,7 +94,7 @@ BTextView::LineBuffer::PixelToLine(float pixel) const
void
BTextView::LineBuffer::BumpOrigin(float delta, long index)
BTextView::LineBuffer::BumpOrigin(float delta, int32 index)
{
for (long i = index; i < fItemCount; i++)
fBuffer[i].origin += delta;
@@ -39,7 +39,7 @@ public:
void BumpOrigin(float delta, int32 index);
void BumpOffset(int32 delta, int32 index);
long NumLines() const;
int32 NumLines() const;
float MaxWidth() const;
STELine* operator[](int32 index) const;
};
@@ -56,7 +56,7 @@ class _BStyleRunDescBuffer_ : public _BTextViewSupportBuffer_<STEStyleRunDesc> {
void InsertDesc(STEStyleRunDesc* inDesc, int32 index);
void RemoveDescs(int32 index, int32 count = 1);
long OffsetToRun(int32 offset) const;
int32 OffsetToRun(int32 offset) const;
void BumpOffset(int32 delta, int32 index);
STEStyleRunDesc* operator[](int32 index) const;
@@ -188,7 +188,7 @@ TextGapBuffer::GetString(int32 fromOffset, int32* _numBytes)
bool
TextGapBuffer::FindChar(char inChar, long fromIndex, long* ioDelta)
TextGapBuffer::FindChar(char inChar, int32 fromIndex, int32* ioDelta)
{
long numChars = *ioDelta;
for (long i = 0; i < numChars; i++) {
@@ -333,7 +333,7 @@ TextGapBuffer::_MoveGapTo(int32 toIndex)
void
TextGapBuffer::_EnlargeGapTo(long inCount)
TextGapBuffer::_EnlargeGapTo(int32 inCount)
{
if (inCount == fGapCount)
return;
@@ -348,7 +348,7 @@ TextGapBuffer::_EnlargeGapTo(long inCount)
void
TextGapBuffer::_ShrinkGapTo(long inCount)
TextGapBuffer::_ShrinkGapTo(int32 inCount)
{
if (inCount == fGapCount)
return;
+3 -3
View File
@@ -359,7 +359,7 @@ DefaultCatalog::WriteToFile(const char *path)
return res;
BMallocIO mallocIO;
mallocIO.SetBlockSize(max(fCatMap.Size() * 20, 256L));
mallocIO.SetBlockSize(max(fCatMap.Size() * 20, (int32)256));
// set a largish block-size in order to avoid reallocs
res = Flatten(&mallocIO);
if (res == B_OK) {
@@ -390,7 +390,7 @@ DefaultCatalog::WriteToAttribute(const entry_ref &appOrAddOnRef)
return res;
BMallocIO mallocIO;
mallocIO.SetBlockSize(max(fCatMap.Size() * 20, 256L));
mallocIO.SetBlockSize(max(fCatMap.Size() * 20, (int32)256));
// set a largish block-size in order to avoid reallocs
res = Flatten(&mallocIO);
@@ -421,7 +421,7 @@ DefaultCatalog::WriteToResource(const entry_ref &appOrAddOnRef)
return res;
BMallocIO mallocIO;
mallocIO.SetBlockSize(max(fCatMap.Size() * 20, 256L));
mallocIO.SetBlockSize(max(fCatMap.Size() * 20, (int32)256));
// set a largish block-size in order to avoid reallocs
res = Flatten(&mallocIO);
+3 -3
View File
@@ -180,14 +180,14 @@ BQueryFile::SetPredicate(const char* predicate)
status_t
BQueryFile::AddVolume(const BVolume& volume)
{
return fVolumes.AddItem((void*)volume.Device()) ? B_OK : B_NO_MEMORY;
return fVolumes.AddItem((void*)(addr_t)volume.Device()) ? B_OK : B_NO_MEMORY;
}
status_t
BQueryFile::AddVolume(dev_t device)
{
return fVolumes.AddItem((void*)device) ? B_OK : B_NO_MEMORY;
return fVolumes.AddItem((void*)(addr_t)device) ? B_OK : B_NO_MEMORY;
}
@@ -211,7 +211,7 @@ BQueryFile::VolumeAt(int32 index) const
if (index < 0 || index >= fVolumes.CountItems())
return -1;
return (dev_t)fVolumes.ItemAt(index);
return (dev_t)(addr_t)fVolumes.ItemAt(index);
}
+1 -1
View File
@@ -1430,7 +1430,7 @@ BAppFileInfo::_ReadData(const char* name, int32 id, type_code type,
error = B_NO_MEMORY;
bufferSize = info.size;
}
if (error == B_OK && bufferSize < info.size)
if (error == B_OK && (off_t)bufferSize < info.size)
error = B_BAD_VALUE;
// read the data
+3 -3
View File
@@ -684,14 +684,14 @@ BEntry::_Dump(const char* name)
printf("------------------------------------------------------------\n");
}
printf("fCStatus == %ld\n", fCStatus);
printf("fCStatus == %" B_PRId32 "\n", fCStatus);
struct stat st;
if (fDirFd != -1
&& _kern_read_stat(fDirFd, NULL, false, &st,
sizeof(struct stat)) == B_OK) {
printf("dir.device == %ld\n", st.st_dev);
printf("dir.inode == %lld\n", st.st_ino);
printf("dir.device == %" B_PRIdDEV "\n", st.st_dev);
printf("dir.inode == %" B_PRIdINO "\n", st.st_ino);
} else {
printf("dir == NullFd\n");
}
+2 -2
View File
@@ -272,7 +272,7 @@ ValueNode<float>::GetString(BString &predicate)
} value;
value.asFloat = fValue;
// int32 value = *reinterpret_cast<int32*>(&fValue);
sprintf(buffer, "0x%08lx", value.asInteger);
sprintf(buffer, "0x%08" B_PRIx32, value.asInteger);
predicate.SetTo(buffer);
return B_OK;
}
@@ -289,7 +289,7 @@ ValueNode<double>::GetString(BString &predicate)
} value;
// int64 value = *reinterpret_cast<int64*>(&fValue);
value.asFloat = fValue;
sprintf(buffer, "0x%016Lx", value.asInteger);
sprintf(buffer, "0x%016" B_PRIx64, value.asInteger);
predicate.SetTo(buffer);
return B_OK;
}
+3 -2
View File
@@ -354,10 +354,11 @@ BPartition::GetPath(BPath* path) const
if (!leaf || strcmp(leaf, "raw") != B_OK)
return B_ERROR;
snprintf(indexBuffer, sizeof(indexBuffer), "%ld", Index());
snprintf(indexBuffer, sizeof(indexBuffer), "%" B_PRId32, Index());
} else {
// Our parent is a normal partition, no device: Append our index.
snprintf(indexBuffer, sizeof(indexBuffer), "%s_%ld", path->Leaf(), Index());
snprintf(indexBuffer, sizeof(indexBuffer), "%s_%" B_PRId32,
path->Leaf(), Index());
}
error = path->GetParent(path);
@@ -220,10 +220,10 @@ BPartitioningInfo::PrintToStream() const
printf("BPartitioningInfo is not initialized\n");
return;
}
printf("BPartitioningInfo has %ld spaces:\n", fCount);
printf("BPartitioningInfo has %" B_PRId32 " spaces:\n", fCount);
for (int32 i = 0; i < fCount; i++) {
printf(" space at %ld: offset = %lld, size = %lld\n",
i, fSpaces[i].offset, fSpaces[i].size);
printf(" space at %" B_PRId32 ": offset = %" B_PRId64 ", size = %"
B_PRId64 "\n", i, fSpaces[i].offset, fSpaces[i].size);
}
}
+2 -2
View File
@@ -34,8 +34,8 @@ Range::GetErr() const {
else {
char start_str[32];
char end_str[32];
sprintf(start_str, "%ld", fStart);
sprintf(end_str, "%ld", fEnd);
sprintf(start_str, "%" B_PRId32, fStart);
sprintf(end_str, "%" B_PRId32, fEnd);
return new Err(std::string("Sniffer Parser Error -- Invalid range: [") + start_str + ":" + end_str + "]", -1);
}
}
+3 -3
View File
@@ -71,7 +71,7 @@ BBufferIO::ReadAt(off_t pos, void* buffer, size_t size)
// If the data we are looking for is not in the buffer...
if (size > fBufferUsed
|| pos < fBufferStart
|| pos > fBufferStart + fBufferUsed
|| pos > fBufferStart + (off_t)fBufferUsed
|| pos + size > fBufferStart + fBufferUsed) {
if (fBufferIsDirty) {
// If there are pending writes, do them.
@@ -119,7 +119,7 @@ BBufferIO::WriteAt(off_t pos, const void* buffer, size_t size)
}
// If we want to write beyond the cached data...
if (pos > fBufferStart + fBufferUsed
if (pos > fBufferStart + (off_t)fBufferUsed
|| pos < fBufferStart) {
ssize_t read;
off_t where = pos;
@@ -245,7 +245,7 @@ BBufferIO::PrintToStream() const
{
printf("stream %p\n", fStream);
printf("buffer %p\n", fBuffer);
printf("start %lld\n", fBufferStart);
printf("start %" B_PRId64 "\n", fBufferStart);
printf("used %ld\n", fBufferUsed);
printf("phys %ld\n", fBufferSize);
printf("dirty %s\n", (fBufferIsDirty) ? "true" : "false");