Return and use constant reference from LVM2_PV_Info::get_vg_name() (!94)

Closes !94 - Make more getter methods use return-by-constant-reference
This commit is contained in:
Mike Fleetwood 2021-11-02 21:18:16 +00:00 committed by Curtis Gedak
parent 55a74645f6
commit c35422a70c
5 changed files with 7 additions and 6 deletions

View File

@ -55,7 +55,7 @@ class LVM2_PV_Info
public:
static bool is_lvm2_pv_supported();
static void clear_cache();
static Glib::ustring get_vg_name( const Glib::ustring & path );
static const Glib::ustring& get_vg_name(const Glib::ustring& path);
static Byte_Value get_size_bytes( const Glib::ustring & path );
static Byte_Value get_free_bytes( const Glib::ustring & path );
static bool has_active_lvs( const Glib::ustring & path );

View File

@ -1463,7 +1463,7 @@ void GParted_Core::set_mountpoints( Partition & partition )
if (partition.fstype == FS_LVM2_PV)
{
Glib::ustring vgname = LVM2_PV_Info::get_vg_name( partition.get_path() );
const Glib::ustring& vgname = LVM2_PV_Info::get_vg_name(partition.get_path());
if ( ! vgname.empty() )
partition.add_mountpoint( vgname );
}
@ -3694,7 +3694,7 @@ bool GParted_Core::filesystem_resize_disallowed( const Partition & partition )
if (partition.fstype == FS_LVM2_PV)
{
//The LVM2 PV can't be resized when it's a member of an export VG
Glib::ustring vgname = LVM2_PV_Info::get_vg_name( partition.get_path() );
const Glib::ustring& vgname = LVM2_PV_Info::get_vg_name(partition.get_path());
if ( vgname .empty() )
return false ;
return LVM2_PV_Info::is_vg_exported( vgname );

View File

@ -87,7 +87,8 @@ void LVM2_PV_Info::clear_cache()
lvm2_pv_info_cache_initialized = false;
}
Glib::ustring LVM2_PV_Info::get_vg_name( const Glib::ustring & path )
const Glib::ustring& LVM2_PV_Info::get_vg_name(const Glib::ustring& path)
{
initialize_if_required() ;
const LVM2_PV& pv = get_pv_cache_entry_by_name(path);

View File

@ -3597,7 +3597,7 @@ bool Win_GParted::remove_non_empty_lvm2_pv_dialog( const OperationType optype )
tmp_msg += "\n\n" ;
tmp_msg += _( "Do you want to continue to forcibly delete the Physical Volume?" ) ;
Glib::ustring vgname = LVM2_PV_Info::get_vg_name( selected_partition_ptr->get_path() );
const Glib::ustring& vgname = LVM2_PV_Info::get_vg_name(selected_partition_ptr->get_path());
std::vector<Glib::ustring> members ;
if ( ! vgname .empty() )
members = LVM2_PV_Info::get_vg_members( vgname );

View File

@ -121,7 +121,7 @@ bool lvm2_pv::check_repair( const Partition & partition, OperationDetail & opera
bool lvm2_pv::remove( const Partition & partition, OperationDetail & operationdetail )
{
Glib::ustring vgname = LVM2_PV_Info::get_vg_name( partition.get_path() );
const Glib::ustring& vgname = LVM2_PV_Info::get_vg_name(partition.get_path());
Glib::ustring cmd ;
if ( vgname .empty() )
cmd = "lvm pvremove " + Glib::shell_quote( partition.get_path() );