Refactor get_device_and_disk() into if fail return early pattern

Again to follow a code pattern slowly being applied.
This commit is contained in:
Mike Fleetwood 2024-09-05 12:53:07 +01:00
parent 37eaa2764f
commit fd322aaa2d
1 changed files with 6 additions and 5 deletions

View File

@ -4143,15 +4143,16 @@ bool GParted_Core::get_disk(PedDevice *lp_device, PedDisk*& lp_disk)
bool GParted_Core::get_device_and_disk(const Glib::ustring& device_path, PedDevice*& lp_device, PedDisk*& lp_disk)
{
if (get_device(device_path, lp_device))
{
if (get_disk(lp_device, lp_disk))
return true;
if (! get_device(device_path, lp_device))
return false;
if (! get_disk(lp_device, lp_disk))
{
destroy_device_and_disk(lp_device, lp_disk);
return false;
}
return false;
return true;
}