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)
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
// the old change: we do this since the same byte is changed twice
// in hex mode editing.
fNewData[fSize - 1] = change->fNewData[0];
#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(fNewData, fSize, "new:");
#endif
@@ -368,31 +370,35 @@ ReplaceChange::GetRange(off_t /*fileSize*/, off_t &_offset, off_t &_size)
DataEditor::DataEditor()
: BLocker("data view")
, fAttribute(NULL)
:
BLocker("data view"),
fAttribute(NULL)
{
}
DataEditor::DataEditor(entry_ref &ref, const char *attribute)
: BLocker("data view")
, fAttribute(NULL)
:
BLocker("data view"),
fAttribute(NULL)
{
SetTo(ref, attribute);
}
DataEditor::DataEditor(BEntry &entry, const char *attribute)
: BLocker("data view")
, fAttribute(NULL)
:
BLocker("data view"),
fAttribute(NULL)
{
SetTo(entry, attribute);
}
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)
return;
int32 firstIndex = fFirstChange != NULL ? fChanges.IndexOf(fFirstChange) + 1 : 0;
int32 firstIndex = fFirstChange != NULL ? fChanges.IndexOf(fFirstChange) + 1
: 0;
int32 lastIndex = fChanges.IndexOf(fLastChange);
if (fChangesFromSaved >= 0) {
// 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++) {
DataChange *change = fChanges.ItemAt(i);
@@ -635,7 +643,8 @@ DataEditor::ApplyChanges()
}
} else {
// 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--) {
DataChange *change = fChanges.ItemAt(i);
@@ -657,7 +666,8 @@ DataEditor::Save()
// 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);
if (fChangesFromSaved < 0 && firstIndex != lastIndex) {
// swap indices
@@ -719,9 +729,10 @@ DataEditor::Save()
size = fSize - fRealViewOffset;
ssize_t bytesWritten;
if (IsAttribute())
bytesWritten = fFile.WriteAttr(fAttribute, fType, fRealViewOffset, fView, size);
else
if (IsAttribute()) {
bytesWritten = fFile.WriteAttr(fAttribute, fType, fRealViewOffset,
fView, size);
} else
bytesWritten = fFile.WriteAt(fRealViewOffset, fView, size);
if (bytesWritten < B_OK)
@@ -948,7 +959,8 @@ DataEditor::Update()
ssize_t bytesRead;
if (IsAttribute()) {
BNode node(&fAttributeRef);
bytesRead = node.ReadAttr(fAttribute, fType, fRealViewOffset, fView, fRealViewSize);
bytesRead = node.ReadAttr(fAttribute, fType, fRealViewOffset, fView,
fRealViewSize);
} else
bytesRead = fFile.ReadAt(fRealViewOffset, fView, fRealViewSize);
@@ -1125,7 +1137,8 @@ DataEditor::Find(off_t startPosition, const uint8 *data, size_t dataSize,
if (matchLastOffset != 0) {
// we had a partial match in the previous block, let's
// check if it is a whole match
if (!compareFunc(fView, data + matchLastOffset, dataSize - matchLastOffset)) {
if (!compareFunc(fView, data + matchLastOffset,
dataSize - matchLastOffset)) {
matchLastOffset = 0;
break;
}