IMHO these are a little better error codes. If fDelegate is NULL, it means

the BDiskDevice of a BPartiton has not been prepared for modifications. To
me, it means the initialization status of the object does not support the
operation, hence B_NO_INIT. B_BAD_DATA hints to me that I have passed invalid
data to a function.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23875 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2008-02-05 15:16:22 +00:00
parent 70c8595603
commit e0b3fc9796

View File

@ -640,8 +640,10 @@ BPartition::FindDescendant(partition_id id) const
status_t status_t
BPartition::GetPartitioningInfo(BPartitioningInfo* info) const BPartition::GetPartitioningInfo(BPartitioningInfo* info) const
{ {
if (!fDelegate || !info) if (!info)
return B_BAD_VALUE; return B_BAD_VALUE;
if (!fDelegate)
return B_NO_INIT;
return fDelegate->GetPartitioningInfo(info); return fDelegate->GetPartitioningInfo(info);
} }
@ -686,7 +688,7 @@ status_t
BPartition::Defragment() const BPartition::Defragment() const
{ {
if (!fDelegate) if (!fDelegate)
return B_BAD_VALUE; return B_NO_INIT;
return fDelegate->Defragment(); return fDelegate->Defragment();
} }
@ -715,7 +717,7 @@ status_t
BPartition::Repair(bool checkOnly) const BPartition::Repair(bool checkOnly) const
{ {
if (!fDelegate) if (!fDelegate)
return B_BAD_VALUE; return B_NO_INIT;
return fDelegate->Repair(checkOnly); return fDelegate->Repair(checkOnly);
} }
@ -748,7 +750,7 @@ BPartition::ValidateResize(off_t* size) const
{ {
BPartition* parent = Parent(); BPartition* parent = Parent();
if (!parent || !fDelegate) if (!parent || !fDelegate)
return B_BAD_VALUE; return B_NO_INIT;
status_t error = parent->fDelegate->ValidateResizeChild(fDelegate, size); status_t error = parent->fDelegate->ValidateResizeChild(fDelegate, size);
if (error != B_OK) if (error != B_OK)
@ -775,7 +777,7 @@ BPartition::Resize(off_t size)
{ {
BPartition* parent = Parent(); BPartition* parent = Parent();
if (!parent || !fDelegate) if (!parent || !fDelegate)
return B_BAD_VALUE; return B_NO_INIT;
status_t error; status_t error;
off_t contentSize = size; off_t contentSize = size;
@ -850,7 +852,7 @@ BPartition::ValidateMove(off_t* offset) const
{ {
BPartition* parent = Parent(); BPartition* parent = Parent();
if (!parent || !fDelegate) if (!parent || !fDelegate)
return B_BAD_VALUE; return B_NO_INIT;
status_t error = parent->fDelegate->ValidateMoveChild(fDelegate, offset); status_t error = parent->fDelegate->ValidateMoveChild(fDelegate, offset);
if (error != B_OK) if (error != B_OK)
@ -876,7 +878,7 @@ BPartition::Move(off_t offset)
{ {
BPartition* parent = Parent(); BPartition* parent = Parent();
if (!parent || !fDelegate) if (!parent || !fDelegate)
return B_BAD_VALUE; return B_NO_INIT;
status_t error = parent->fDelegate->MoveChild(fDelegate, offset); status_t error = parent->fDelegate->MoveChild(fDelegate, offset);
if (error != B_OK) if (error != B_OK)
@ -911,7 +913,7 @@ BPartition::ValidateSetName(BString* name) const
{ {
BPartition* parent = Parent(); BPartition* parent = Parent();
if (!parent || !fDelegate) if (!parent || !fDelegate)
return B_BAD_VALUE; return B_NO_INIT;
return parent->fDelegate->ValidateSetName(fDelegate, name); return parent->fDelegate->ValidateSetName(fDelegate, name);
} }
@ -923,7 +925,7 @@ BPartition::SetName(const char* name)
{ {
BPartition* parent = Parent(); BPartition* parent = Parent();
if (!parent || !fDelegate) if (!parent || !fDelegate)
return B_BAD_VALUE; return B_NO_INIT;
return parent->fDelegate->SetName(fDelegate, name); return parent->fDelegate->SetName(fDelegate, name);
} }
@ -944,7 +946,7 @@ status_t
BPartition::ValidateSetContentName(BString* name) const BPartition::ValidateSetContentName(BString* name) const
{ {
if (!fDelegate) if (!fDelegate)
return B_BAD_VALUE; return B_NO_INIT;
return fDelegate->ValidateSetContentName(name); return fDelegate->ValidateSetContentName(name);
} }
@ -955,7 +957,7 @@ status_t
BPartition::SetContentName(const char* name) BPartition::SetContentName(const char* name)
{ {
if (!fDelegate) if (!fDelegate)
return B_BAD_VALUE; return B_NO_INIT;
return fDelegate->SetContentName(name); return fDelegate->SetContentName(name);
} }
@ -980,7 +982,7 @@ BPartition::ValidateSetType(const char* type) const
{ {
BPartition* parent = Parent(); BPartition* parent = Parent();
if (!parent || !fDelegate) if (!parent || !fDelegate)
return B_BAD_VALUE; return B_NO_INIT;
return parent->fDelegate->ValidateSetType(fDelegate, type); return parent->fDelegate->ValidateSetType(fDelegate, type);
} }
@ -992,7 +994,7 @@ BPartition::SetType(const char* type)
{ {
BPartition* parent = Parent(); BPartition* parent = Parent();
if (!parent || !fDelegate) if (!parent || !fDelegate)
return B_BAD_VALUE; return B_NO_INIT;
return parent->fDelegate->SetType(fDelegate, type); return parent->fDelegate->SetType(fDelegate, type);
} }
@ -1017,7 +1019,7 @@ BPartition::GetParameterEditor(BDiskDeviceParameterEditor** editor)
{ {
BPartition* parent = Parent(); BPartition* parent = Parent();
if (!parent || !fDelegate) if (!parent || !fDelegate)
return B_BAD_VALUE; return B_NO_INIT;
return parent->fDelegate->GetParameterEditor(fDelegate, editor); return parent->fDelegate->GetParameterEditor(fDelegate, editor);
} }
@ -1029,7 +1031,7 @@ BPartition::SetParameters(const char* parameters)
{ {
BPartition* parent = Parent(); BPartition* parent = Parent();
if (!parent || !fDelegate) if (!parent || !fDelegate)
return B_BAD_VALUE; return B_NO_INIT;
return parent->fDelegate->SetParameters(fDelegate, parameters); return parent->fDelegate->SetParameters(fDelegate, parameters);
} }
@ -1050,7 +1052,7 @@ status_t
BPartition::GetContentParameterEditor(BDiskDeviceParameterEditor** editor) BPartition::GetContentParameterEditor(BDiskDeviceParameterEditor** editor)
{ {
if (!fDelegate) if (!fDelegate)
return B_BAD_VALUE; return B_NO_INIT;
return fDelegate->GetContentParameterEditor(editor); return fDelegate->GetContentParameterEditor(editor);
} }
@ -1061,7 +1063,7 @@ status_t
BPartition::SetContentParameters(const char* parameters) BPartition::SetContentParameters(const char* parameters)
{ {
if (!fDelegate) if (!fDelegate)
return B_BAD_VALUE; return B_NO_INIT;
return fDelegate->SetContentParameters(parameters); return fDelegate->SetContentParameters(parameters);
} }
@ -1073,7 +1075,7 @@ BPartition::GetNextSupportedType(int32 *cookie, BString* type) const
{ {
BPartition* parent = Parent(); BPartition* parent = Parent();
if (!parent || !fDelegate) if (!parent || !fDelegate)
return false; return B_NO_INIT;
return parent->fDelegate->GetNextSupportedChildType(fDelegate, cookie, return parent->fDelegate->GetNextSupportedChildType(fDelegate, cookie,
type); type);
@ -1085,7 +1087,7 @@ status_t
BPartition::GetNextSupportedChildType(int32 *cookie, BString* type) const BPartition::GetNextSupportedChildType(int32 *cookie, BString* type) const
{ {
if (!fDelegate) if (!fDelegate)
return B_BAD_VALUE; return B_NO_INIT;
return fDelegate->GetNextSupportedChildType(NULL, cookie, type); return fDelegate->GetNextSupportedChildType(NULL, cookie, type);
} }
@ -1117,7 +1119,7 @@ BPartition::GetInitializationParameterEditor(const char* diskSystem,
BDiskDeviceParameterEditor** editor) const BDiskDeviceParameterEditor** editor) const
{ {
if (!fDelegate) if (!fDelegate)
return B_BAD_VALUE; return B_NO_INIT;
return fDelegate->GetInitializationParameterEditor(diskSystem, editor); return fDelegate->GetInitializationParameterEditor(diskSystem, editor);
} }
@ -1129,7 +1131,7 @@ BPartition::ValidateInitialize(const char* diskSystem, BString* name,
const char* parameters) const char* parameters)
{ {
if (!fDelegate) if (!fDelegate)
return B_BAD_VALUE; return B_NO_INIT;
return fDelegate->ValidateInitialize(diskSystem, name, parameters); return fDelegate->ValidateInitialize(diskSystem, name, parameters);
} }
@ -1141,7 +1143,7 @@ BPartition::Initialize(const char* diskSystem, const char* name,
const char* parameters) const char* parameters)
{ {
if (!fDelegate) if (!fDelegate)
return B_BAD_VALUE; return B_NO_INIT;
return fDelegate->Initialize(diskSystem, name, parameters); return fDelegate->Initialize(diskSystem, name, parameters);
} }
@ -1152,7 +1154,7 @@ status_t
BPartition::Uninitialize() BPartition::Uninitialize()
{ {
// TODO: Implement! // TODO: Implement!
return B_BAD_VALUE; return B_NOT_SUPPORTED;
} }
@ -1170,7 +1172,7 @@ BPartition::GetChildCreationParameterEditor(const char* type,
BDiskDeviceParameterEditor** editor) const BDiskDeviceParameterEditor** editor) const
{ {
if (!fDelegate) if (!fDelegate)
return B_BAD_VALUE; return B_NO_INIT;
return fDelegate->GetChildCreationParameterEditor(type, editor); return fDelegate->GetChildCreationParameterEditor(type, editor);
} }
@ -1182,7 +1184,7 @@ BPartition::ValidateCreateChild(off_t* offset, off_t* size, const char* type,
BString* name, const char* parameters) const BString* name, const char* parameters) const
{ {
if (!fDelegate) if (!fDelegate)
return B_BAD_VALUE; return B_NO_INIT;
return fDelegate->ValidateCreateChild(offset, size, type, name, parameters); return fDelegate->ValidateCreateChild(offset, size, type, name, parameters);
} }
@ -1194,7 +1196,7 @@ BPartition::CreateChild(off_t offset, off_t size, const char* type,
const char* name, const char* parameters, BPartition** child) const char* name, const char* parameters, BPartition** child)
{ {
if (!fDelegate) if (!fDelegate)
return B_BAD_VALUE; return B_NO_INIT;
return fDelegate->CreateChild(offset, size, type, name, parameters, child); return fDelegate->CreateChild(offset, size, type, name, parameters, child);
} }
@ -1217,8 +1219,10 @@ BPartition::CanDeleteChild(int32 index) const
status_t status_t
BPartition::DeleteChild(int32 index) BPartition::DeleteChild(int32 index)
{ {
if (!fDelegate)
return B_NO_INIT;
BPartition* child = ChildAt(index); BPartition* child = ChildAt(index);
if (!fDelegate || !child || child->Parent() != this) if (!child || child->Parent() != this)
return B_BAD_VALUE; return B_BAD_VALUE;
return fDelegate->DeleteChild(child->fDelegate); return fDelegate->DeleteChild(child->fDelegate);
@ -1525,7 +1529,7 @@ status_t
BPartition::_CreateDelegates() BPartition::_CreateDelegates()
{ {
if (fDelegate || !fPartitionData) if (fDelegate || !fPartitionData)
return B_BAD_VALUE; return B_NO_INIT;
// create and init delegate // create and init delegate
fDelegate = new(nothrow) Delegate(this); fDelegate = new(nothrow) Delegate(this);