Diskprobe: some 64 bit fixes
* also warnings about comparisons between signed and non signed.
This commit is contained in:
@@ -236,8 +236,10 @@ void
|
|||||||
ReplaceChange::Apply(off_t bufferOffset, uint8 *buffer, size_t bufferSize)
|
ReplaceChange::Apply(off_t bufferOffset, uint8 *buffer, size_t bufferSize)
|
||||||
{
|
{
|
||||||
// is it in our range?
|
// is it in our range?
|
||||||
if (fOffset > bufferOffset + bufferSize || fOffset + fSize < bufferOffset)
|
if (fOffset > (bufferOffset + (off_t)bufferSize)
|
||||||
|
|| (fOffset + (off_t)fSize) < bufferOffset) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// don't change anything outside the supplied buffer
|
// don't change anything outside the supplied buffer
|
||||||
off_t offset = fOffset;
|
off_t offset = fOffset;
|
||||||
@@ -263,8 +265,10 @@ void
|
|||||||
ReplaceChange::Revert(off_t bufferOffset, uint8 *buffer, size_t bufferSize)
|
ReplaceChange::Revert(off_t bufferOffset, uint8 *buffer, size_t bufferSize)
|
||||||
{
|
{
|
||||||
// is it in our range?
|
// is it in our range?
|
||||||
if (fOffset - bufferOffset > bufferSize || fOffset + fSize < bufferOffset)
|
if ((fOffset - bufferOffset) > (off_t)bufferSize
|
||||||
|
|| (fOffset + (off_t)fSize) < bufferOffset) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// don't change anything outside the supplied buffer
|
// don't change anything outside the supplied buffer
|
||||||
off_t offset = fOffset;
|
off_t offset = fOffset;
|
||||||
@@ -307,8 +311,8 @@ ReplaceChange::Merge(DataChange *_change)
|
|||||||
|
|
||||||
// are the changes adjacent?
|
// are the changes adjacent?
|
||||||
|
|
||||||
if (change->fOffset + change->fSize != fOffset
|
if ((change->fOffset + (off_t)change->fSize) != fOffset
|
||||||
&& fOffset + fSize != change->fOffset)
|
&& (fOffset + (off_t)fSize) != change->fOffset)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// okay, we can try to merge the two changes
|
// okay, we can try to merge the two changes
|
||||||
@@ -560,7 +564,7 @@ DataEditor::Replace(off_t offset, const uint8 *data, size_t length)
|
|||||||
|
|
||||||
if (offset >= fSize)
|
if (offset >= fSize)
|
||||||
return B_BAD_VALUE;
|
return B_BAD_VALUE;
|
||||||
if (offset + length > fSize)
|
if ((offset + (off_t)length) > fSize)
|
||||||
length = fSize - offset;
|
length = fSize - offset;
|
||||||
|
|
||||||
if (fNeedsUpdate) {
|
if (fNeedsUpdate) {
|
||||||
@@ -705,7 +709,7 @@ DataEditor::Save()
|
|||||||
|
|
||||||
// don't try to change the file size
|
// don't try to change the file size
|
||||||
size_t size = fRealViewSize;
|
size_t size = fRealViewSize;
|
||||||
if (fRealViewOffset + fRealViewSize > fSize)
|
if ((fRealViewOffset + (off_t)fRealViewSize) > (off_t)fSize)
|
||||||
size = fSize - fRealViewOffset;
|
size = fSize - fRealViewOffset;
|
||||||
|
|
||||||
ssize_t bytesWritten;
|
ssize_t bytesWritten;
|
||||||
@@ -1125,7 +1129,7 @@ DataEditor::Find(off_t startPosition, const uint8 *data, size_t dataSize,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = firstByte; i < fRealViewSize; i++) {
|
for (size_t i = firstByte; i < fRealViewSize; i++) {
|
||||||
if (position + i + dataSize > fSize)
|
if (position + (off_t)(i + dataSize) > (off_t)fSize)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!compareFunc(fView + i, data, 1)) {
|
if (!compareFunc(fView + i, data, 1)) {
|
||||||
|
|||||||
@@ -163,19 +163,19 @@ DataView::UpdateFromEditor(BMessage *message)
|
|||||||
if (message != NULL
|
if (message != NULL
|
||||||
&& message->FindInt64("offset", &offset) == B_OK
|
&& message->FindInt64("offset", &offset) == B_OK
|
||||||
&& message->FindInt64("size", &size) == B_OK) {
|
&& message->FindInt64("size", &size) == B_OK) {
|
||||||
if (offset > fOffset + fDataSize
|
if (offset > fOffset + (off_t)fDataSize
|
||||||
|| offset + size < fOffset) {
|
|| offset + (off_t)size < fOffset) {
|
||||||
// the changes are not within our scope, so we can ignore them
|
// the changes are not within our scope, so we can ignore them
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset > fOffset)
|
if (offset > fOffset)
|
||||||
start = offset - fOffset;
|
start = offset - fOffset;
|
||||||
if (offset + size < fOffset + fDataSize)
|
if (offset + (off_t)size < fOffset + (off_t)fDataSize)
|
||||||
end = offset + size - fOffset;
|
end = offset + size - fOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fOffset + fDataSize > fFileSize)
|
if (fOffset + (off_t)fDataSize > fFileSize)
|
||||||
fSizeInView = fFileSize - fOffset;
|
fSizeInView = fFileSize - fOffset;
|
||||||
else
|
else
|
||||||
fSizeInView = fDataSize;
|
fSizeInView = fDataSize;
|
||||||
@@ -356,8 +356,8 @@ DataView::ConvertLine(char *line, off_t offset, const uint8 *buffer, size_t size
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
line += sprintf(line, fBase == kHexBase ? "%0*Lx: " : "%0*Ld: ",
|
line += sprintf(line, fBase == kHexBase ? "%0*" B_PRIxOFF": " : "%0*"
|
||||||
(int)fPositionLength, offset);
|
B_PRIdOFF": ", (int)fPositionLength, offset);
|
||||||
|
|
||||||
for (uint32 i = 0; i < kBlockSize; i++) {
|
for (uint32 i = 0; i < kBlockSize; i++) {
|
||||||
if (i >= size) {
|
if (i >= size) {
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ get_type_string(char *buffer, size_t bufferSize, type_code type)
|
|||||||
for (int32 i = 0; i < 4; i++) {
|
for (int32 i = 0; i < 4; i++) {
|
||||||
buffer[i] = type >> (24 - 8 * i);
|
buffer[i] = type >> (24 - 8 * i);
|
||||||
if (buffer[i] < ' ' || buffer[i] == 0x7f) {
|
if (buffer[i] < ' ' || buffer[i] == 0x7f) {
|
||||||
snprintf(buffer, bufferSize, "0x%04lx", type);
|
snprintf(buffer, bufferSize, "0x%04" B_PRIx32, type);
|
||||||
break;
|
break;
|
||||||
} else if (i == 3)
|
} else if (i == 3)
|
||||||
buffer[4] = '\0';
|
buffer[4] = '\0';
|
||||||
@@ -705,7 +705,8 @@ HeaderView::UpdateIcon()
|
|||||||
void
|
void
|
||||||
HeaderView::FormatValue(char *buffer, size_t bufferSize, off_t value)
|
HeaderView::FormatValue(char *buffer, size_t bufferSize, off_t value)
|
||||||
{
|
{
|
||||||
snprintf(buffer, bufferSize, fBase == kHexBase ? "0x%Lx" : "%Ld", value);
|
snprintf(buffer, bufferSize, fBase == kHexBase ? "0x%" B_PRIxOFF : "%"
|
||||||
|
B_PRIdOFF, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1550,7 +1551,7 @@ ProbeView::AttachedToWindow()
|
|||||||
const uint32 blockSizes[] = {512, 1024, 2048};
|
const uint32 blockSizes[] = {512, 1024, 2048};
|
||||||
for (uint32 i = 0; i < sizeof(blockSizes) / sizeof(blockSizes[0]); i++) {
|
for (uint32 i = 0; i < sizeof(blockSizes) / sizeof(blockSizes[0]); i++) {
|
||||||
char buffer[32];
|
char buffer[32];
|
||||||
snprintf(buffer, sizeof(buffer), "%ld%s", blockSizes[i],
|
snprintf(buffer, sizeof(buffer), "%" B_PRId32 "%s", blockSizes[i],
|
||||||
fEditor.IsDevice() && fEditor.BlockSize() == blockSizes[i]
|
fEditor.IsDevice() && fEditor.BlockSize() == blockSizes[i]
|
||||||
? B_TRANSLATE(" (native)") : "");
|
? B_TRANSLATE(" (native)") : "");
|
||||||
subMenu->AddItem(item = new BMenuItem(buffer,
|
subMenu->AddItem(item = new BMenuItem(buffer,
|
||||||
@@ -1582,7 +1583,7 @@ ProbeView::AttachedToWindow()
|
|||||||
fontSize = 0;
|
fontSize = 0;
|
||||||
for (uint32 i = 0; i < sizeof(fontSizes) / sizeof(fontSizes[0]); i++) {
|
for (uint32 i = 0; i < sizeof(fontSizes) / sizeof(fontSizes[0]); i++) {
|
||||||
char buffer[16];
|
char buffer[16];
|
||||||
snprintf(buffer, sizeof(buffer), "%ld", fontSizes[i]);
|
snprintf(buffer, sizeof(buffer), "%" B_PRId32, fontSizes[i]);
|
||||||
subMenu->AddItem(item = new BMenuItem(buffer,
|
subMenu->AddItem(item = new BMenuItem(buffer,
|
||||||
message = new BMessage(kMsgFontSize)));
|
message = new BMessage(kMsgFontSize)));
|
||||||
message->AddFloat("font_size", fontSizes[i]);
|
message->AddFloat("font_size", fontSizes[i]);
|
||||||
@@ -1653,23 +1654,30 @@ ProbeView::_UpdateSelectionMenuItems(int64 start, int64 end)
|
|||||||
// update menu items
|
// update menu items
|
||||||
|
|
||||||
char buffer[128];
|
char buffer[128];
|
||||||
if (fDataView->Base() == kHexBase)
|
if (fDataView->Base() == kHexBase) {
|
||||||
snprintf(buffer, sizeof(buffer), B_TRANSLATE("Native: 0x%0*Lx"), size * 2, position);
|
snprintf(buffer, sizeof(buffer), B_TRANSLATE("Native: 0x%0*Lx"),
|
||||||
else
|
size * 2, position);
|
||||||
snprintf(buffer, sizeof(buffer), B_TRANSLATE("Native: %Ld (0x%0*Lx)"), position, size * 2, position);
|
} else {
|
||||||
|
snprintf(buffer, sizeof(buffer), B_TRANSLATE("Native: %Ld (0x%0*Lx)"),
|
||||||
|
position, size * 2, position);
|
||||||
|
}
|
||||||
|
|
||||||
fNativeMenuItem->SetLabel(buffer);
|
fNativeMenuItem->SetLabel(buffer);
|
||||||
fNativeMenuItem->SetEnabled(position >= 0 && (position * fEditor.BlockSize()) < fEditor.FileSize());
|
fNativeMenuItem->SetEnabled(position >= 0
|
||||||
|
&& (off_t)(position * fEditor.BlockSize()) < fEditor.FileSize());
|
||||||
fNativeMenuItem->Message()->ReplaceInt64("block", position);
|
fNativeMenuItem->Message()->ReplaceInt64("block", position);
|
||||||
|
|
||||||
position = B_SWAP_INT64(position) >> (8 * (8 - size));
|
position = B_SWAP_INT64(position) >> (8 * (8 - size));
|
||||||
if (fDataView->Base() == kHexBase)
|
if (fDataView->Base() == kHexBase) {
|
||||||
snprintf(buffer, sizeof(buffer), B_TRANSLATE("Swapped: 0x%0*Lx"), size * 2, position);
|
snprintf(buffer, sizeof(buffer), B_TRANSLATE("Swapped: 0x%0*Lx"),
|
||||||
else
|
size * 2, position);
|
||||||
snprintf(buffer, sizeof(buffer), B_TRANSLATE("Swapped: %Ld (0x%0*Lx)"), position, size * 2, position);
|
} else {
|
||||||
|
snprintf(buffer, sizeof(buffer), B_TRANSLATE("Swapped: %Ld (0x%0*Lx)"),
|
||||||
|
position, size * 2, position);
|
||||||
|
}
|
||||||
|
|
||||||
fSwappedMenuItem->SetLabel(buffer);
|
fSwappedMenuItem->SetLabel(buffer);
|
||||||
fSwappedMenuItem->SetEnabled(position >= 0 && (position * fEditor.BlockSize()) < fEditor.FileSize());
|
fSwappedMenuItem->SetEnabled(position >= 0 && (off_t)(position * fEditor.BlockSize()) < fEditor.FileSize());
|
||||||
fSwappedMenuItem->Message()->ReplaceInt64("block", position);
|
fSwappedMenuItem->Message()->ReplaceInt64("block", position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ StringEditor::_UpdateText()
|
|||||||
|
|
||||||
size_t viewSize = fEditor.ViewSize();
|
size_t viewSize = fEditor.ViewSize();
|
||||||
// that may need some more memory...
|
// that may need some more memory...
|
||||||
if (viewSize < fEditor.FileSize())
|
if ((off_t)viewSize < fEditor.FileSize())
|
||||||
fEditor.SetViewSize(fEditor.FileSize());
|
fEditor.SetViewSize(fEditor.FileSize());
|
||||||
|
|
||||||
const char *buffer;
|
const char *buffer;
|
||||||
@@ -486,7 +486,7 @@ NumberEditor::_UpdateText()
|
|||||||
bool
|
bool
|
||||||
NumberEditor::TypeMatches()
|
NumberEditor::TypeMatches()
|
||||||
{
|
{
|
||||||
return fEditor.FileSize() >= _Size();
|
return fEditor.FileSize() >= (off_t)_Size();
|
||||||
// we only look at as many bytes we need to
|
// we only look at as many bytes we need to
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -949,7 +949,7 @@ ImageView::_UpdateImage()
|
|||||||
|
|
||||||
size_t viewSize = fEditor.ViewSize();
|
size_t viewSize = fEditor.ViewSize();
|
||||||
// that may need some more memory...
|
// that may need some more memory...
|
||||||
if (viewSize < fEditor.FileSize())
|
if ((off_t)viewSize < fEditor.FileSize())
|
||||||
fEditor.SetViewSize(fEditor.FileSize());
|
fEditor.SetViewSize(fEditor.FileSize());
|
||||||
|
|
||||||
const char *data;
|
const char *data;
|
||||||
@@ -1169,7 +1169,7 @@ MessageView::_TypeToString(type_code type)
|
|||||||
for (int32 i = 0; i < 4; i++) {
|
for (int32 i = 0; i < 4; i++) {
|
||||||
text[i] = type >> (24 - 8 * i);
|
text[i] = type >> (24 - 8 * i);
|
||||||
if (text[i] < ' ' || text[i] == 0x7f) {
|
if (text[i] < ' ' || text[i] == 0x7f) {
|
||||||
snprintf(text, sizeof(text), "0x%04lx", type);
|
snprintf(text, sizeof(text), "0x%04" B_PRIx32, type);
|
||||||
break;
|
break;
|
||||||
} else if (i == 3)
|
} else if (i == 3)
|
||||||
text[4] = '\0';
|
text[4] = '\0';
|
||||||
@@ -1226,16 +1226,16 @@ MessageView::SetTo(BMessage& message)
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case B_INT64_TYPE:
|
case B_INT64_TYPE:
|
||||||
snprintf(text, sizeof(text), "%Ld", *(int64*)data);
|
snprintf(text, sizeof(text), "%" B_PRId64, *(int64*)data);
|
||||||
break;
|
break;
|
||||||
case B_UINT64_TYPE:
|
case B_UINT64_TYPE:
|
||||||
snprintf(text, sizeof(text), "%Lu", *(uint64*)data);
|
snprintf(text, sizeof(text), "%" B_PRIu64, *(uint64*)data);
|
||||||
break;
|
break;
|
||||||
case B_INT32_TYPE:
|
case B_INT32_TYPE:
|
||||||
snprintf(text, sizeof(text), "%ld", *(int32*)data);
|
snprintf(text, sizeof(text), "%" B_PRId32, *(int32*)data);
|
||||||
break;
|
break;
|
||||||
case B_UINT32_TYPE:
|
case B_UINT32_TYPE:
|
||||||
snprintf(text, sizeof(text), "%lu", *(uint32*)data);
|
snprintf(text, sizeof(text), "%" B_PRIu32, *(uint32*)data);
|
||||||
break;
|
break;
|
||||||
case B_BOOL_TYPE:
|
case B_BOOL_TYPE:
|
||||||
if (*(uint8*)data)
|
if (*(uint8*)data)
|
||||||
@@ -1255,7 +1255,7 @@ MessageView::SetTo(BMessage& message)
|
|||||||
fTextView->Insert("\t\t");
|
fTextView->Insert("\t\t");
|
||||||
if (count > 1) {
|
if (count > 1) {
|
||||||
char index[16];
|
char index[16];
|
||||||
snprintf(index, sizeof(index), "%ld.\t", j);
|
snprintf(index, sizeof(index), "%" B_PRId32 ".\t", j);
|
||||||
fTextView->Insert(index);
|
fTextView->Insert(index);
|
||||||
}
|
}
|
||||||
fTextView->Insert(text);
|
fTextView->Insert(text);
|
||||||
@@ -1273,7 +1273,7 @@ MessageView::_UpdateMessage()
|
|||||||
|
|
||||||
size_t viewSize = fEditor.ViewSize();
|
size_t viewSize = fEditor.ViewSize();
|
||||||
// that may need some more memory...
|
// that may need some more memory...
|
||||||
if (viewSize < fEditor.FileSize())
|
if ((off_t)viewSize < fEditor.FileSize())
|
||||||
fEditor.SetViewSize(fEditor.FileSize());
|
fEditor.SetViewSize(fEditor.FileSize());
|
||||||
|
|
||||||
const char *buffer;
|
const char *buffer;
|
||||||
|
|||||||
Reference in New Issue
Block a user