Refactor reiser4::read_uuid() into if fail return early pattern

This commit is contained in:
Mike Fleetwood 2021-03-20 15:45:50 +00:00 committed by Curtis Gedak
parent 975d9ecdc9
commit 2a76af5beb
1 changed files with 11 additions and 10 deletions

View File

@ -127,23 +127,24 @@ void reiser4::read_label( Partition & partition )
} }
} }
void reiser4::read_uuid( Partition & partition ) void reiser4::read_uuid( Partition & partition )
{ {
if ( ! Utils::execute_command( "debugfs.reiser4 " + Glib::shell_quote( partition.get_path() ), exit_status = Utils::execute_command("debugfs.reiser4 " + Glib::shell_quote( partition.get_path()),
output, error, true ) ) output, error, true);
{ if (exit_status != 0)
partition .uuid = Utils::regexp_label( output, "uuid:[[:blank:]]*(" RFC4122_NONE_NIL_UUID_REGEXP ")" ) ;
}
else
{ {
if (! output.empty()) if (! output.empty())
partition.push_back_message(output); partition.push_back_message(output);
if (! error.empty()) if (! error.empty())
partition.push_back_message(error); partition.push_back_message(error);
return;
} }
partition.uuid = Utils::regexp_label(output, "uuid:[[:blank:]]*(" RFC4122_NONE_NIL_UUID_REGEXP ")");
} }
bool reiser4::create( const Partition & new_partition, OperationDetail & operationdetail ) bool reiser4::create( const Partition & new_partition, OperationDetail & operationdetail )
{ {
return ! execute_command( "mkfs.reiser4 --force --yes --label " + return ! execute_command( "mkfs.reiser4 --force --yes --label " +