DiskProbe: style fixes...

This commit is contained in:
Adrien Destugues
2014-11-20 15:08:09 +01:00
parent b0ee8bf20a
commit 1e4a6aa2e5
+32 -19
View File
@@ -296,13 +296,15 @@ ReplaceChange::Merge(DataChange *_change)
if (change == NULL) if (change == NULL)
return false; return false;
if (change->fOffset + change->fSize == fOffset + fSize && change->fSize == 1) { if (change->fOffset + change->fSize == fOffset + fSize
&& change->fSize == 1) {
// this is a special case - the new change changed the last byte of // this is a special case - the new change changed the last byte of
// the old change: we do this since the same byte is changed twice // the old change: we do this since the same byte is changed twice
// in hex mode editing. // in hex mode editing.
fNewData[fSize - 1] = change->fNewData[0]; fNewData[fSize - 1] = change->fNewData[0];
#ifdef TRACE_DATA_EDITOR #ifdef TRACE_DATA_EDITOR
printf("Merge one byte %p (offset = %Ld, size = %lu):\n", this, fOffset, fSize); printf("Merge one byte %p (offset = %Ld, size = %lu):\n", this, fOffset,
fSize);
dump_block(fOldData, fSize, "old:"); dump_block(fOldData, fSize, "old:");
dump_block(fNewData, fSize, "new:"); dump_block(fNewData, fSize, "new:");
#endif #endif
@@ -368,31 +370,35 @@ ReplaceChange::GetRange(off_t /*fileSize*/, off_t &_offset, off_t &_size)
DataEditor::DataEditor() DataEditor::DataEditor()
: BLocker("data view") :
, fAttribute(NULL) BLocker("data view"),
fAttribute(NULL)
{ {
} }
DataEditor::DataEditor(entry_ref &ref, const char *attribute) DataEditor::DataEditor(entry_ref &ref, const char *attribute)
: BLocker("data view") :
, fAttribute(NULL) BLocker("data view"),
fAttribute(NULL)
{ {
SetTo(ref, attribute); SetTo(ref, attribute);
} }
DataEditor::DataEditor(BEntry &entry, const char *attribute) DataEditor::DataEditor(BEntry &entry, const char *attribute)
: BLocker("data view") :
, fAttribute(NULL) BLocker("data view"),
fAttribute(NULL)
{ {
SetTo(entry, attribute); SetTo(entry, attribute);
} }
DataEditor::DataEditor(const DataEditor &editor) DataEditor::DataEditor(const DataEditor &editor)
: BLocker("data view") :
, fAttribute(NULL) BLocker("data view"),
fAttribute(NULL)
{ {
} }
@@ -622,12 +628,14 @@ DataEditor::ApplyChanges()
if (fLastChange == NULL && fFirstChange == NULL) if (fLastChange == NULL && fFirstChange == NULL)
return; return;
int32 firstIndex = fFirstChange != NULL ? fChanges.IndexOf(fFirstChange) + 1 : 0; int32 firstIndex = fFirstChange != NULL ? fChanges.IndexOf(fFirstChange) + 1
: 0;
int32 lastIndex = fChanges.IndexOf(fLastChange); int32 lastIndex = fChanges.IndexOf(fLastChange);
if (fChangesFromSaved >= 0) { if (fChangesFromSaved >= 0) {
// ascend changes // ascend changes
TRACE(("ApplyChanges(): ascend from %ld to %ld\n", firstIndex, lastIndex)); TRACE(("ApplyChanges(): ascend from %ld to %ld\n", firstIndex,
lastIndex));
for (int32 i = firstIndex; i <= lastIndex; i++) { for (int32 i = firstIndex; i <= lastIndex; i++) {
DataChange *change = fChanges.ItemAt(i); DataChange *change = fChanges.ItemAt(i);
@@ -635,7 +643,8 @@ DataEditor::ApplyChanges()
} }
} else { } else {
// descend changes // descend changes
TRACE(("ApplyChanges(): descend from %ld to %ld\n", firstIndex - 1, lastIndex)); TRACE(("ApplyChanges(): descend from %ld to %ld\n", firstIndex - 1,
lastIndex));
for (int32 i = firstIndex - 1; i > lastIndex; i--) { for (int32 i = firstIndex - 1; i > lastIndex; i--) {
DataChange *change = fChanges.ItemAt(i); DataChange *change = fChanges.ItemAt(i);
@@ -657,7 +666,8 @@ DataEditor::Save()
// Do we need to ascend or descend the list of changes? // Do we need to ascend or descend the list of changes?
int32 firstIndex = fFirstChange != NULL ? fChanges.IndexOf(fFirstChange) + 1 : 0; int32 firstIndex = fFirstChange != NULL ? fChanges.IndexOf(fFirstChange) + 1
: 0;
int32 lastIndex = fChanges.IndexOf(fLastChange); int32 lastIndex = fChanges.IndexOf(fLastChange);
if (fChangesFromSaved < 0 && firstIndex != lastIndex) { if (fChangesFromSaved < 0 && firstIndex != lastIndex) {
// swap indices // swap indices
@@ -719,9 +729,10 @@ DataEditor::Save()
size = fSize - fRealViewOffset; size = fSize - fRealViewOffset;
ssize_t bytesWritten; ssize_t bytesWritten;
if (IsAttribute()) if (IsAttribute()) {
bytesWritten = fFile.WriteAttr(fAttribute, fType, fRealViewOffset, fView, size); bytesWritten = fFile.WriteAttr(fAttribute, fType, fRealViewOffset,
else fView, size);
} else
bytesWritten = fFile.WriteAt(fRealViewOffset, fView, size); bytesWritten = fFile.WriteAt(fRealViewOffset, fView, size);
if (bytesWritten < B_OK) if (bytesWritten < B_OK)
@@ -948,7 +959,8 @@ DataEditor::Update()
ssize_t bytesRead; ssize_t bytesRead;
if (IsAttribute()) { if (IsAttribute()) {
BNode node(&fAttributeRef); BNode node(&fAttributeRef);
bytesRead = node.ReadAttr(fAttribute, fType, fRealViewOffset, fView, fRealViewSize); bytesRead = node.ReadAttr(fAttribute, fType, fRealViewOffset, fView,
fRealViewSize);
} else } else
bytesRead = fFile.ReadAt(fRealViewOffset, fView, fRealViewSize); bytesRead = fFile.ReadAt(fRealViewOffset, fView, fRealViewSize);
@@ -1125,7 +1137,8 @@ DataEditor::Find(off_t startPosition, const uint8 *data, size_t dataSize,
if (matchLastOffset != 0) { if (matchLastOffset != 0) {
// we had a partial match in the previous block, let's // we had a partial match in the previous block, let's
// check if it is a whole match // check if it is a whole match
if (!compareFunc(fView, data + matchLastOffset, dataSize - matchLastOffset)) { if (!compareFunc(fView, data + matchLastOffset,
dataSize - matchLastOffset)) {
matchLastOffset = 0; matchLastOffset = 0;
break; break;
} }