C++11: Convert NULL to nullptr (!117)

In C++11, nullptr [1] is the strongly typed value to use instead of the
macro NULL [2].  Use everywhere [3][4].

[1] nullptr, the pointer literal (since C++11)
    https://en.cppreference.com/w/cpp/language/nullptr
[2] NULL
    https://en.cppreference.com/w/cpp/types/NULL
[3] Bjarne Stroustrup's C++ Style and Technique FAQ, Should I use NULL
    or 0?
    https://www.stroustrup.com/bs_faq2.html#null
        "In C++, the definition of NULL is 0, so there is only an
        aesthetic difference.  I prefer to avoid macros, so I use 0.
        Another problem with NULL is that people sometimes mistakenly
        believe that it is different from 0 and/or not an integer.  In
        pre-standard code, NULL was/is sometimes defined to something
        unsuitable and therefore had/has to be avoided.  That's less
        common these days.

        If you have to name the null pointer, call it nullptr; that's
        what it's called in C++11.  Then, "nullptr" will be a keyword.
        "
[4] What is nullptr in C++? Advantages, Use Cases & Examples
    https://favtutor.com/blogs/nullptr-cpp
        "Advantages of nullptr
        ...
        Compatible: Null pointers are compatible with null pointer
        constants in the C style (such as NULL and 0).  This implies
        that old C code that uses these constants and null pointers can
        communicate with each other in C++.
        "

Closes !117 - Require C++11 compilation
This commit is contained in:
Mike Fleetwood 2023-08-31 21:08:59 +01:00 committed by Curtis Gedak
parent 6bf7668f8e
commit 40665913bf
29 changed files with 296 additions and 294 deletions

View File

@ -212,7 +212,7 @@ private:
// operations applied to partitions for displaying in the UI. // operations applied to partitions for displaying in the UI.
const Partition * selected_partition_ptr; // Pointer to the selected partition. (Alias to element const Partition * selected_partition_ptr; // Pointer to the selected partition. (Alias to element
// in Win_GParted::m_display_device.partitions[] vector). // in Win_GParted::m_display_device.partitions[] vector).
const Partition * copied_partition; // NULL or copy of source partition object. const Partition* copied_partition; // nullptr or copy of source partition object.
std::vector<Operation *> operations; std::vector<Operation *> operations;
//gui stuff //gui stuff

View File

@ -163,8 +163,8 @@ bool DMRaid::is_dmraid_device( const Glib::ustring & dev_path )
if ( ! device_found && file_test( dev_path, Glib::FILE_TEST_IS_SYMLINK ) ) if ( ! device_found && file_test( dev_path, Glib::FILE_TEST_IS_SYMLINK ) )
{ {
//Path is a symbolic link so find real path //Path is a symbolic link so find real path
char * rpath = realpath( dev_path.c_str(), NULL ); char* rpath = realpath(dev_path.c_str(), nullptr);
if ( rpath != NULL ) if (rpath != nullptr)
{ {
Glib::ustring tmp_path = rpath; Glib::ustring tmp_path = rpath;
free( rpath ); free( rpath );
@ -233,8 +233,8 @@ Glib::ustring DMRaid::get_dmraid_name( const Glib::ustring & dev_path )
if ( dmraid_name .empty() && file_test( dev_path, Glib::FILE_TEST_IS_SYMLINK ) ) if ( dmraid_name .empty() && file_test( dev_path, Glib::FILE_TEST_IS_SYMLINK ) )
{ {
//Path is a symbolic link so find real path //Path is a symbolic link so find real path
char * rpath = realpath( dev_path.c_str(), NULL ); char* rpath = realpath(dev_path.c_str(), nullptr);
if ( rpath != NULL ) if (rpath != nullptr)
{ {
Glib::ustring tmp_path = rpath; Glib::ustring tmp_path = rpath;
free( rpath ); free( rpath );

View File

@ -31,7 +31,7 @@ namespace GParted
Dialog_Base_Partition::Dialog_Base_Partition(const Device& device) Dialog_Base_Partition::Dialog_Base_Partition(const Device& device)
: m_device(device) : m_device(device)
{ {
frame_resizer_base = NULL; frame_resizer_base = nullptr;
GRIP = false ; GRIP = false ;
this ->fixed_start = false ; this ->fixed_start = false ;
this ->set_resizable( false ); this ->set_resizable( false );
@ -165,7 +165,7 @@ void Dialog_Base_Partition::Set_Resizer( bool extended )
const Partition & Dialog_Base_Partition::Get_New_Partition() const Partition & Dialog_Base_Partition::Get_New_Partition()
{ {
g_assert( new_partition != NULL ); // Bug: Not initialised by derived Dialog_Partition_*() constructor calling set_data() g_assert(new_partition != nullptr); // Bug: Not initialised by derived Dialog_Partition_*() constructor calling set_data()
prepare_new_partition(); prepare_new_partition();
return *new_partition; return *new_partition;
@ -173,7 +173,7 @@ const Partition & Dialog_Base_Partition::Get_New_Partition()
void Dialog_Base_Partition::prepare_new_partition() void Dialog_Base_Partition::prepare_new_partition()
{ {
g_assert( new_partition != NULL ); // Bug: Not initialised by derived Dialog_Partition_*() constructor calling set_data() g_assert(new_partition != nullptr); // Bug: Not initialised by derived Dialog_Partition_*() constructor calling set_data()
Sector old_size = new_partition->get_sector_length(); Sector old_size = new_partition->get_sector_length();

View File

@ -43,7 +43,7 @@ Dialog_Partition_Copy::Dialog_Partition_Copy(const Device& device, const FS& fs,
Dialog_Partition_Copy::~Dialog_Partition_Copy() Dialog_Partition_Copy::~Dialog_Partition_Copy()
{ {
delete new_partition; delete new_partition;
new_partition = NULL; new_partition = nullptr;
} }
void Dialog_Partition_Copy::set_data( const Partition & selected_partition, const Partition & copied_partition ) void Dialog_Partition_Copy::set_data( const Partition & selected_partition, const Partition & copied_partition )
@ -145,7 +145,7 @@ void Dialog_Partition_Copy::set_data( const Partition & selected_partition, cons
const Partition & Dialog_Partition_Copy::Get_New_Partition() const Partition & Dialog_Partition_Copy::Get_New_Partition()
{ {
g_assert( new_partition != NULL ); // Bug: Not initialised by constructor calling set_data() g_assert(new_partition != nullptr); // Bug: Not initialised by constructor calling set_data()
//first call baseclass to get the correct new partition //first call baseclass to get the correct new partition
Dialog_Base_Partition::prepare_new_partition(); Dialog_Base_Partition::prepare_new_partition();

View File

@ -51,7 +51,7 @@ Dialog_Partition_New::Dialog_Partition_New( const Device & device,
Dialog_Partition_New::~Dialog_Partition_New() Dialog_Partition_New::~Dialog_Partition_New()
{ {
delete new_partition; delete new_partition;
new_partition = NULL; new_partition = nullptr;
// Work around a Gtk issue fixed in 3.24.0. // Work around a Gtk issue fixed in 3.24.0.
// https://gitlab.gnome.org/GNOME/gtk/issues/125 // https://gitlab.gnome.org/GNOME/gtk/issues/125
@ -212,7 +212,7 @@ void Dialog_Partition_New::set_data( const Device & device,
const Partition & Dialog_Partition_New::Get_New_Partition() const Partition & Dialog_Partition_New::Get_New_Partition()
{ {
g_assert( new_partition != NULL ); // Bug: Not initialised by constructor calling set_data() g_assert(new_partition != nullptr); // Bug: Not initialised by constructor calling set_data()
PartitionType part_type ; PartitionType part_type ;
Sector new_start, new_end; Sector new_start, new_end;
@ -339,7 +339,7 @@ const Partition & Dialog_Partition_New::Get_New_Partition()
void Dialog_Partition_New::combobox_changed(bool combo_type_changed) void Dialog_Partition_New::combobox_changed(bool combo_type_changed)
{ {
g_assert( new_partition != NULL ); // Bug: Not initialised by constructor calling set_data() g_assert(new_partition != nullptr); // Bug: Not initialised by constructor calling set_data()
// combo_type // combo_type
if (combo_type_changed) if (combo_type_changed)
@ -414,7 +414,8 @@ void Dialog_Partition_New::combobox_changed(bool combo_type_changed)
void Dialog_Partition_New::build_filesystems_combo(bool only_unformatted) void Dialog_Partition_New::build_filesystems_combo(bool only_unformatted)
{ {
g_assert( new_partition != NULL ); // Bug: Not initialised by constructor calling set_data() g_assert(new_partition != nullptr); // Bug: Not initialised by constructor calling set_data()
combo_filesystem.items().clear(); combo_filesystem.items().clear();
// Fill the file system combobox // Fill the file system combobox

View File

@ -40,7 +40,7 @@ Dialog_Partition_Resize_Move::Dialog_Partition_Resize_Move(const Device& device,
Dialog_Partition_Resize_Move::~Dialog_Partition_Resize_Move() Dialog_Partition_Resize_Move::~Dialog_Partition_Resize_Move()
{ {
delete new_partition; delete new_partition;
new_partition = NULL; new_partition = nullptr;
} }
void Dialog_Partition_Resize_Move::set_data( const Partition & selected_partition, void Dialog_Partition_Resize_Move::set_data( const Partition & selected_partition,
@ -78,7 +78,7 @@ void Dialog_Partition_Resize_Move::set_data( const Partition & selected_partitio
void Dialog_Partition_Resize_Move::Resize_Move_Normal( const PartitionVector & partitions ) void Dialog_Partition_Resize_Move::Resize_Move_Normal( const PartitionVector & partitions )
{ {
g_assert( new_partition != NULL ); // Bug: Not initialised by constructor calling set_data() g_assert(new_partition != nullptr); // Bug: Not initialised by constructor calling set_data()
// Don't permit shrinking an existing file system (other than linux-swap) when the // Don't permit shrinking an existing file system (other than linux-swap) when the
// usage is unknown as that sets the minimum resize. // usage is unknown as that sets the minimum resize.
@ -118,7 +118,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const PartitionVector & p
Sector previous, next ; Sector previous, next ;
previous = next = 0 ; previous = next = 0 ;
const Partition* prev_unalloc_partition = NULL; const Partition* prev_unalloc_partition = nullptr;
//also check the partitions file system ( if this is a 'resize-only' then previous should be 0 ) //also check the partitions file system ( if this is a 'resize-only' then previous should be 0 )
if (t >= 1 && partitions[t-1].type == TYPE_UNALLOCATED && ! this->fixed_start) if (t >= 1 && partitions[t-1].type == TYPE_UNALLOCATED && ! this->fixed_start)
{ {
@ -157,7 +157,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const PartitionVector & p
// Only need to use MIN_SPACE_BEFORE_MB to reserve 1 MiB to protect the partition // Only need to use MIN_SPACE_BEFORE_MB to reserve 1 MiB to protect the partition
// table or EBR if there is a previous unallocated partition allowing the start of // table or EBR if there is a previous unallocated partition allowing the start of
// this selected partition to be resize/moved to the left. // this selected partition to be resize/moved to the left.
if (prev_unalloc_partition == NULL) if (prev_unalloc_partition == nullptr)
MIN_SPACE_BEFORE_MB = 0 ; MIN_SPACE_BEFORE_MB = 0 ;
else else
MIN_SPACE_BEFORE_MB = Dialog_Base_Partition::MB_Needed_for_Boot_Record(*prev_unalloc_partition); MIN_SPACE_BEFORE_MB = Dialog_Base_Partition::MB_Needed_for_Boot_Record(*prev_unalloc_partition);
@ -231,7 +231,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Normal( const PartitionVector & p
void Dialog_Partition_Resize_Move::Resize_Move_Extended( const PartitionVector & partitions ) void Dialog_Partition_Resize_Move::Resize_Move_Extended( const PartitionVector & partitions )
{ {
g_assert( new_partition != NULL ); // Bug: Not initialised by constructor calling set_data() g_assert(new_partition != nullptr); // Bug: Not initialised by constructor calling set_data()
set_title(Glib::ustring::compose(_("Resize/Move %1"), new_partition->get_path())); set_title(Glib::ustring::compose(_("Resize/Move %1"), new_partition->get_path()));
@ -243,7 +243,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const PartitionVector &
Sector previous, next ; Sector previous, next ;
previous = next = 0 ; previous = next = 0 ;
const Partition* prev_unalloc_partition = NULL; const Partition* prev_unalloc_partition = nullptr;
//calculate length and start of previous //calculate length and start of previous
if (t > 0 && partitions[t-1].type == TYPE_UNALLOCATED) if (t > 0 && partitions[t-1].type == TYPE_UNALLOCATED)
{ {
@ -263,7 +263,7 @@ void Dialog_Partition_Resize_Move::Resize_Move_Extended( const PartitionVector &
// Only need to use MIN_SPACE_BEFORE_MB to reserve 1 MiB to protect the partition // Only need to use MIN_SPACE_BEFORE_MB to reserve 1 MiB to protect the partition
// table or EBR if there is a previous unallocated partition allowing the start of // table or EBR if there is a previous unallocated partition allowing the start of
// this selected partition to be resize/moved to the left. // this selected partition to be resize/moved to the left.
if (prev_unalloc_partition == NULL) if (prev_unalloc_partition == nullptr)
MIN_SPACE_BEFORE_MB = 0 ; MIN_SPACE_BEFORE_MB = 0 ;
else else
MIN_SPACE_BEFORE_MB = Dialog_Base_Partition::MB_Needed_for_Boot_Record(*prev_unalloc_partition); MIN_SPACE_BEFORE_MB = Dialog_Base_Partition::MB_Needed_for_Boot_Record(*prev_unalloc_partition);

View File

@ -164,7 +164,7 @@ void Dialog_Rescue_Data::on_view_clicked(int nPart)
char tmpDir[32]=tmp_prefix; char tmpDir[32]=tmp_prefix;
char * tmpDirResult = mkdtemp(tmpDir); char * tmpDirResult = mkdtemp(tmpDir);
if ( tmpDirResult == NULL ) if (tmpDirResult == nullptr)
{ {
Glib::ustring error_txt = _("An error occurred while creating a temporary directory for use as a mount point."); Glib::ustring error_txt = _("An error occurred while creating a temporary directory for use as a mount point.");
error_txt += "\n"; error_txt += "\n";
@ -212,8 +212,8 @@ void Dialog_Rescue_Data::on_view_clicked(int nPart)
/* Opens the default browser in a directory */ /* Opens the default browser in a directory */
void Dialog_Rescue_Data::open_ro_view(Glib::ustring mountPoint) void Dialog_Rescue_Data::open_ro_view(Glib::ustring mountPoint)
{ {
GError *error = NULL ; GError* error = nullptr;
GdkScreen *gscreen = NULL ; GdkScreen* gscreen = nullptr;
Glib::ustring uri = "file:" + mountPoint ; Glib::ustring uri = "file:" + mountPoint ;
@ -221,7 +221,7 @@ void Dialog_Rescue_Data::open_ro_view(Glib::ustring mountPoint)
gtk_show_uri( gscreen, uri .c_str(), gtk_get_current_event_time(), &error ) ; gtk_show_uri( gscreen, uri .c_str(), gtk_get_current_event_time(), &error ) ;
if ( error != NULL ) if (error != nullptr)
{ {
Glib::ustring sec_text(_("Error:")); Glib::ustring sec_text(_("Error:"));
sec_text.append("\n"); sec_text.append("\n");

View File

@ -33,7 +33,7 @@ namespace GParted
DrawingAreaVisualDisk::DrawingAreaVisualDisk() DrawingAreaVisualDisk::DrawingAreaVisualDisk()
{ {
selected_vp = NULL ; selected_vp = nullptr;
// Set some standard colors // Set some standard colors
color_used .set( Utils::get_color( GParted::FS_USED ) ); color_used .set( Utils::get_color( GParted::FS_USED ) );
@ -57,7 +57,7 @@ void DrawingAreaVisualDisk::load_partitions( const PartitionVector & partitions,
void DrawingAreaVisualDisk::set_selected( const Partition * partition_ptr ) void DrawingAreaVisualDisk::set_selected( const Partition * partition_ptr )
{ {
selected_vp = NULL ; selected_vp = nullptr;
set_selected( visual_partitions, partition_ptr ); set_selected( visual_partitions, partition_ptr );
queue_draw() ; queue_draw() ;
@ -66,7 +66,7 @@ void DrawingAreaVisualDisk::set_selected( const Partition * partition_ptr )
void DrawingAreaVisualDisk::clear() void DrawingAreaVisualDisk::clear()
{ {
visual_partitions .clear() ; visual_partitions .clear() ;
selected_vp = NULL ; selected_vp = nullptr;
queue_resize() ; queue_resize() ;
} }
@ -343,7 +343,7 @@ bool DrawingAreaVisualDisk::on_button_press_event( GdkEventButton * event )
{ {
bool ret_val = Gtk::DrawingArea::on_button_press_event( event ) ; bool ret_val = Gtk::DrawingArea::on_button_press_event( event ) ;
selected_vp = NULL ; selected_vp = nullptr;
set_selected( visual_partitions, static_cast<int>( event ->x ), static_cast<int>( event ->y ) ) ; set_selected( visual_partitions, static_cast<int>( event ->x ), static_cast<int>( event ->y ) ) ;
queue_draw() ; queue_draw() ;

View File

@ -91,7 +91,7 @@ int FileSystem::execute_command( const Glib::ustring & command, OperationDetail
{ {
StreamSlot empty_stream_slot; StreamSlot empty_stream_slot;
TimedSlot empty_timed_slot; TimedSlot empty_timed_slot;
return execute_command_internal(command, NULL, operationdetail, flags, empty_stream_slot, empty_timed_slot); return execute_command_internal(command, nullptr, operationdetail, flags, empty_stream_slot, empty_timed_slot);
} }
@ -114,7 +114,7 @@ int FileSystem::execute_command( const Glib::ustring & command, OperationDetail
StreamSlot stream_progress_slot ) StreamSlot stream_progress_slot )
{ {
TimedSlot empty_timed_slot; TimedSlot empty_timed_slot;
return execute_command_internal(command, NULL, operationdetail, flags, stream_progress_slot, empty_timed_slot); return execute_command_internal(command, nullptr, operationdetail, flags, stream_progress_slot, empty_timed_slot);
} }
@ -125,7 +125,7 @@ int FileSystem::execute_command( const Glib::ustring & command, OperationDetail
TimedSlot timed_progress_slot ) TimedSlot timed_progress_slot )
{ {
StreamSlot empty_stream_slot; StreamSlot empty_stream_slot;
return execute_command_internal(command, NULL, operationdetail, flags, empty_stream_slot, timed_progress_slot); return execute_command_internal(command, nullptr, operationdetail, flags, empty_stream_slot, timed_progress_slot);
} }
@ -150,7 +150,7 @@ int FileSystem::execute_command_internal(const Glib::ustring& command, const cha
Glib::SPAWN_DO_NOT_REAP_CHILD | Glib::SPAWN_SEARCH_PATH, Glib::SPAWN_DO_NOT_REAP_CHILD | Glib::SPAWN_SEARCH_PATH,
sigc::ptr_fun(setup_child), sigc::ptr_fun(setup_child),
&pid, &pid,
(input != NULL) ? &in : 0, (input != nullptr) ? &in : 0,
&out, &out,
&err ); &err );
} catch (Glib::SpawnError &e) { } catch (Glib::SpawnError &e) {
@ -194,7 +194,7 @@ int FileSystem::execute_command_internal(const Glib::ustring& command, const cha
pid, pid,
flags & EXEC_CANCEL_SAFE ) ); flags & EXEC_CANCEL_SAFE ) );
if (input != NULL && in != -1) if (input != nullptr && in != -1)
{ {
// Write small amount of input to pipe to the child process. Linux will // Write small amount of input to pipe to the child process. Linux will
// always accept up to 4096 bytes without blocking. See pipe(7). // always accept up to 4096 bytes without blocking. See pipe(7).
@ -252,7 +252,7 @@ Glib::ustring FileSystem::mk_temp_dir( const Glib::ustring & infix, OperationDet
operationdetail .add_child( OperationDetail( operationdetail .add_child( OperationDetail(
Glib::ustring( "mkdir -v " ) + dir_buf, STATUS_EXECUTE, FONT_BOLD_ITALIC ) ) ; Glib::ustring( "mkdir -v " ) + dir_buf, STATUS_EXECUTE, FONT_BOLD_ITALIC ) ) ;
const char * dir_name = mkdtemp( dir_buf ) ; const char * dir_name = mkdtemp( dir_buf ) ;
if ( NULL == dir_name ) if (nullptr == dir_name)
{ {
int e = errno ; int e = errno ;
operationdetail .get_last_child() .add_child( OperationDetail( operationdetail .get_last_child() .add_child( OperationDetail(

View File

@ -201,7 +201,7 @@ void GParted_Core::set_devices_thread( std::vector<Device> * pdevices )
ped_device_probe_all(); ped_device_probe_all();
} }
PedDevice* lp_device = ped_device_get_next( NULL ) ; PedDevice* lp_device = ped_device_get_next(nullptr);
while ( lp_device ) while ( lp_device )
{ {
/* TO TRANSLATORS: looks like Confirming /dev/sda */ /* TO TRANSLATORS: looks like Confirming /dev/sda */
@ -243,7 +243,7 @@ void GParted_Core::set_devices_thread( std::vector<Device> * pdevices )
#endif #endif
PedDevice* lp_device = ped_device_get( device_paths[t].c_str() ); PedDevice* lp_device = ped_device_get( device_paths[t].c_str() );
if ( lp_device == NULL || ! useable_device( lp_device ) ) if (lp_device == nullptr || ! useable_device(lp_device))
{ {
// Remove this disk device which isn't useable // Remove this disk device which isn't useable
device_paths.erase( device_paths.begin() + t-- ); device_paths.erase( device_paths.begin() + t-- );
@ -272,7 +272,7 @@ void GParted_Core::set_devices_thread( std::vector<Device> * pdevices )
} }
set_thread_status_message("") ; set_thread_status_message("") ;
g_idle_add( (GSourceFunc)_mainquit, NULL ); g_idle_add((GSourceFunc)_mainquit, nullptr);
} }
// runs gpart on the specified parameter // runs gpart on the specified parameter
@ -516,11 +516,11 @@ bool GParted_Core::new_disklabel( const Glib::ustring & device_path, const Glib:
{ {
bool return_value = false ; bool return_value = false ;
PedDevice* lp_device = NULL ; PedDevice* lp_device = nullptr;
PedDisk* lp_disk = NULL ; PedDisk* lp_disk = nullptr;
if ( get_device( device_path, lp_device ) ) if ( get_device( device_path, lp_device ) )
{ {
PedDiskType *type = NULL ; PedDiskType* type = nullptr;
type = ped_disk_type_get( disklabel .c_str() ) ; type = ped_disk_type_get( disklabel .c_str() ) ;
if ( type ) if ( type )
@ -549,8 +549,8 @@ bool GParted_Core::new_disklabel( const Glib::ustring & device_path, const Glib:
bool GParted_Core::toggle_flag( const Partition & partition, const Glib::ustring & flag, bool state ) bool GParted_Core::toggle_flag( const Partition & partition, const Glib::ustring & flag, bool state )
{ {
bool succes = false ; bool succes = false ;
PedDevice* lp_device = NULL ; PedDevice* lp_device = nullptr;
PedDisk* lp_disk = NULL ; PedDisk* lp_disk = nullptr;
if ( get_device_and_disk( partition .device_path, lp_device, lp_disk ) ) if ( get_device_and_disk( partition .device_path, lp_device, lp_disk ) )
{ {
PedPartition* lp_partition = get_lp_partition( lp_disk, partition ); PedPartition* lp_partition = get_lp_partition( lp_disk, partition );
@ -590,7 +590,7 @@ std::vector<Glib::ustring> GParted_Core::get_disklabeltypes()
std::vector<Glib::ustring> disklabeltypes ; std::vector<Glib::ustring> disklabeltypes ;
PedDiskType *disk_type ; PedDiskType *disk_type ;
for ( disk_type = ped_disk_type_get_next( NULL ) ; disk_type ; disk_type = ped_disk_type_get_next( disk_type ) ) for (disk_type = ped_disk_type_get_next(nullptr); disk_type; disk_type = ped_disk_type_get_next(disk_type))
disklabeltypes .push_back( disk_type->name ) ; disklabeltypes .push_back( disk_type->name ) ;
return disklabeltypes ; return disklabeltypes ;
@ -600,8 +600,8 @@ std::map<Glib::ustring, bool> GParted_Core::get_available_flags( const Partition
{ {
std::map<Glib::ustring, bool> flag_info ; std::map<Glib::ustring, bool> flag_info ;
PedDevice* lp_device = NULL ; PedDevice* lp_device = nullptr;
PedDisk* lp_disk = NULL ; PedDisk* lp_disk = nullptr;
if ( get_device_and_disk( partition .device_path, lp_device, lp_disk ) ) if ( get_device_and_disk( partition .device_path, lp_device, lp_disk ) )
{ {
PedPartition* lp_partition = get_lp_partition( lp_disk, partition ); PedPartition* lp_partition = get_lp_partition( lp_disk, partition );
@ -624,13 +624,13 @@ std::map<Glib::ustring, bool> GParted_Core::get_available_flags( const Partition
Glib::ustring GParted_Core::get_partition_path(const PedPartition *lp_partition) Glib::ustring GParted_Core::get_partition_path(const PedPartition *lp_partition)
{ {
g_assert(lp_partition != NULL); // Bug: Not initialised by suitable ped_disk_*partition*() call g_assert(lp_partition != nullptr); // Bug: Not initialised by suitable ped_disk_*partition*() call
char * lp_path; //we have to free the result of ped_partition_get_path() char * lp_path; //we have to free the result of ped_partition_get_path()
Glib::ustring partition_path = "Partition path not found"; Glib::ustring partition_path = "Partition path not found";
lp_path = ped_partition_get_path(lp_partition); lp_path = ped_partition_get_path(lp_partition);
if ( lp_path != NULL ) if (lp_path != nullptr)
{ {
partition_path = lp_path; partition_path = lp_path;
free(lp_path); free(lp_path);
@ -653,8 +653,8 @@ Glib::ustring GParted_Core::get_partition_path(const PedPartition *lp_partition)
void GParted_Core::set_device_from_disk( Device & device, const Glib::ustring & device_path ) void GParted_Core::set_device_from_disk( Device & device, const Glib::ustring & device_path )
{ {
PedDevice* lp_device = NULL; PedDevice* lp_device = nullptr;
PedDisk* lp_disk = NULL; PedDisk* lp_disk = nullptr;
if (! get_device(device_path, lp_device, true)) if (! get_device(device_path, lp_device, true))
return; return;
@ -677,7 +677,7 @@ void GParted_Core::set_device_from_disk( Device & device, const Glib::ustring &
device.cylsize = MEBIBYTE / device.sector_size; device.cylsize = MEBIBYTE / device.sector_size;
std::vector<Glib::ustring> messages; std::vector<Glib::ustring> messages;
FSType fstype = detect_filesystem(lp_device, NULL, messages); FSType fstype = detect_filesystem(lp_device, nullptr, messages);
if (fstype != FS_UNKNOWN) if (fstype != FS_UNKNOWN)
{ {
@ -826,11 +826,11 @@ void GParted_Core::set_device_partitions( Device & device, PedDevice* lp_device,
//clear partitions //clear partitions
device .partitions .clear() ; device .partitions .clear() ;
PedPartition* lp_partition = ped_disk_next_partition( lp_disk, NULL ) ; PedPartition* lp_partition = ped_disk_next_partition(lp_disk, nullptr);
while ( lp_partition ) while ( lp_partition )
{ {
libparted_messages .clear() ; libparted_messages .clear() ;
Partition * partition_temp = NULL; Partition* partition_temp = nullptr;
bool partition_is_busy = false ; bool partition_is_busy = false ;
FSType fstype; FSType fstype;
std::vector<Glib::ustring> detect_messages; std::vector<Glib::ustring> detect_messages;
@ -930,7 +930,7 @@ void GParted_Core::set_device_partitions( Device & device, PedDevice* lp_device,
// Only for libparted reported partition types that we care about: NORMAL, // Only for libparted reported partition types that we care about: NORMAL,
// LOGICAL, EXTENDED // LOGICAL, EXTENDED
if ( partition_temp != NULL ) if (partition_temp != nullptr)
{ {
set_partition_label_and_uuid( *partition_temp ); set_partition_label_and_uuid( *partition_temp );
set_mountpoints( *partition_temp ); set_mountpoints( *partition_temp );
@ -986,7 +986,7 @@ void GParted_Core::set_device_one_partition( Device & device, PedDevice * lp_dev
Glib::ustring path = lp_device->path; Glib::ustring path = lp_device->path;
bool partition_is_busy = is_busy(device.get_path(), fstype, path); bool partition_is_busy = is_busy(device.get_path(), fstype, path);
Partition * partition_temp = NULL; Partition* partition_temp = nullptr;
if ( fstype == FS_LUKS ) if ( fstype == FS_LUKS )
partition_temp = new PartitionLUKS(); partition_temp = new PartitionLUKS();
else else
@ -1008,7 +1008,7 @@ void GParted_Core::set_device_one_partition( Device & device, PedDevice * lp_dev
set_partition_label_and_uuid( *partition_temp ); set_partition_label_and_uuid( *partition_temp );
set_mountpoints( *partition_temp ); set_mountpoints( *partition_temp );
set_used_sectors( *partition_temp, NULL ); set_used_sectors(*partition_temp, nullptr);
device.partitions.push_back_adopt( partition_temp ); device.partitions.push_back_adopt( partition_temp );
} }
@ -1039,7 +1039,7 @@ void GParted_Core::set_luks_partition( PartitionLUKS & partition )
set_partition_label_and_uuid( encrypted ); set_partition_label_and_uuid( encrypted );
set_mountpoints( encrypted ); set_mountpoints( encrypted );
set_used_sectors( encrypted, NULL ); set_used_sectors(encrypted, nullptr);
} }
void GParted_Core::set_partition_label_and_uuid( Partition & partition ) void GParted_Core::set_partition_label_and_uuid( Partition & partition )
@ -1095,18 +1095,18 @@ FSType GParted_Core::detect_filesystem_in_encryption_mapping(const Glib::ustring
FSType fstype = FS_UNKNOWN; FSType fstype = FS_UNKNOWN;
PedDevice *lp_device = NULL; PedDevice* lp_device = nullptr;
if (get_device(path, lp_device)) if (get_device(path, lp_device))
{ {
// Run libparted partition table and file system identification. Only use // Run libparted partition table and file system identification. Only use
// (get the first partition) if it's a "loop" table; because GParted only // (get the first partition) if it's a "loop" table; because GParted only
// supports one block device to one encryption mapping to one file system. // supports one block device to one encryption mapping to one file system.
PedDisk *lp_disk = NULL; PedDisk* lp_disk = nullptr;
PedPartition *lp_partition = NULL; PedPartition* lp_partition = nullptr;
if (get_disk(lp_device, lp_disk) && lp_disk && lp_disk->type && if (get_disk(lp_device, lp_disk) && lp_disk && lp_disk->type &&
lp_disk->type->name && strcmp(lp_disk->type->name, "loop") == 0 ) lp_disk->type->name && strcmp(lp_disk->type->name, "loop") == 0 )
{ {
lp_partition = ped_disk_next_partition(lp_disk, NULL); lp_partition = ped_disk_next_partition(lp_disk, nullptr);
} }
// Clear the "unrecognised disk label" message reported when libparted // Clear the "unrecognised disk label" message reported when libparted
// fails to detect anything. // fails to detect anything.
@ -1148,19 +1148,19 @@ FSType GParted_Core::detect_filesystem_internal(const Glib::ustring& path, Byte_
FSType fstype; FSType fstype;
} signatures[] = { } signatures[] = {
//offset1, sig1 , offset2, sig2 , fstype //offset1, sig1 , offset2, sig2 , fstype
{ 0LL, "LUKS\xBA\xBE" , 0LL, NULL , FS_LUKS }, { 0LL, "LUKS\xBA\xBE" , 0LL, nullptr, FS_LUKS },
{ 3LL, "-FVE-FS-" , 0LL, NULL , FS_BITLOCKER }, { 3LL, "-FVE-FS-" , 0LL, nullptr, FS_BITLOCKER },
{ 0LL, "\x52\x56\xBE\x1B", 0LL, NULL , FS_GRUB2_CORE_IMG }, { 0LL, "\x52\x56\xBE\x1B", 0LL, nullptr, FS_GRUB2_CORE_IMG },
{ 0LL, "\x52\x56\xBE\x6F", 0LL, NULL , FS_GRUB2_CORE_IMG }, { 0LL, "\x52\x56\xBE\x6F", 0LL, nullptr, FS_GRUB2_CORE_IMG },
{ 0LL, "\x52\xE8\x28\x01", 0LL, NULL , FS_GRUB2_CORE_IMG }, { 0LL, "\x52\xE8\x28\x01", 0LL, nullptr, FS_GRUB2_CORE_IMG },
{ 0LL, "\x52\xBF\xF4\x81", 0LL, NULL , FS_GRUB2_CORE_IMG }, { 0LL, "\x52\xBF\xF4\x81", 0LL, nullptr, FS_GRUB2_CORE_IMG },
{ 0LL, "\x52\x56\xBE\x63", 0LL, NULL , FS_GRUB2_CORE_IMG }, { 0LL, "\x52\x56\xBE\x63", 0LL, nullptr, FS_GRUB2_CORE_IMG },
{ 0LL, "\x52\x56\xBE\x56", 0LL, NULL , FS_GRUB2_CORE_IMG }, { 0LL, "\x52\x56\xBE\x56", 0LL, nullptr, FS_GRUB2_CORE_IMG },
{ 24LL, "\x01\x00" , 32LL, "NXSB", FS_APFS }, { 24LL, "\x01\x00" , 32LL, "NXSB" , FS_APFS },
{ 512LL, "LABELONE" , 536LL, "LVM2", FS_LVM2_PV }, { 512LL, "LABELONE" , 536LL, "LVM2" , FS_LVM2_PV },
{ 1030LL, "\x34\x34" , 0LL, NULL , FS_NILFS2 }, { 1030LL, "\x34\x34" , 0LL, nullptr, FS_NILFS2 },
{ 65536LL, "ReIsEr4" , 0LL, NULL , FS_REISER4 }, { 65536LL, "ReIsEr4" , 0LL, nullptr, FS_REISER4 },
{ 65600LL, "_BHRfS_M" , 0LL, NULL , FS_BTRFS } { 65600LL, "_BHRfS_M" , 0LL, nullptr, FS_BTRFS }
}; };
// For simple BitLocker recognition consider validation of BIOS Parameter block // For simple BitLocker recognition consider validation of BIOS Parameter block
// fields unnecessary. // fields unnecessary.
@ -1189,14 +1189,14 @@ FSType GParted_Core::detect_filesystem_internal(const Glib::ustring& path, Byte_
for ( unsigned int i = 0 ; i < sizeof( signatures ) / sizeof( signatures[0] ) ; i ++ ) for ( unsigned int i = 0 ; i < sizeof( signatures ) / sizeof( signatures[0] ) ; i ++ )
{ {
const size_t len1 = std::min( ( signatures[i].sig1 == NULL ) ? 0U : strlen( signatures[i].sig1 ), const size_t len1 = std::min((signatures[i].sig1 == nullptr) ? 0U : strlen(signatures[i].sig1),
sizeof( magic1 ) ); sizeof(magic1));
const size_t len2 = std::min( ( signatures[i].sig2 == NULL ) ? 0U : strlen( signatures[i].sig2 ), const size_t len2 = std::min((signatures[i].sig2 == nullptr) ? 0U : strlen(signatures[i].sig2),
sizeof( magic2 ) ); sizeof(magic2));
// NOTE: From this point onwards signatures[].sig1 and .sig2 are treated // NOTE: From this point onwards signatures[].sig1 and .sig2 are treated
// as character buffers of known lengths len1 and len2, not NUL terminated // as character buffers of known lengths len1 and len2, not NUL terminated
// strings. // strings.
if ( len1 == 0UL || ( signatures[i].sig2 != NULL && len2 == 0UL ) ) if (len1 == 0UL || (signatures[i].sig2 != nullptr && len2 == 0UL))
continue; // Don't allow 0 length signatures to match continue; // Don't allow 0 length signatures to match
Byte_Value read_offset = signatures[i].offset1 / sector_size * sector_size; Byte_Value read_offset = signatures[i].offset1 / sector_size * sector_size;
@ -1220,11 +1220,11 @@ FSType GParted_Core::detect_filesystem_internal(const Glib::ustring& path, Byte_
memcpy(magic1, buf + signatures[i].offset1 % sector_size, len1); memcpy(magic1, buf + signatures[i].offset1 % sector_size, len1);
// WARNING: This assumes offset2 is in the same sector as offset1 // WARNING: This assumes offset2 is in the same sector as offset1
if (signatures[i].sig2 != NULL) if (signatures[i].sig2 != nullptr)
memcpy(magic2, buf + signatures[i].offset2 % sector_size, len2); memcpy(magic2, buf + signatures[i].offset2 % sector_size, len2);
if (memcmp(magic1, signatures[i].sig1, len1) == 0 && if (memcmp(magic1, signatures[i].sig1, len1) == 0 &&
(signatures[i].sig2 == NULL || memcmp(magic2, signatures[i].sig2, len2) == 0) ) (signatures[i].sig2 == nullptr || memcmp(magic2, signatures[i].sig2, len2) == 0) )
{ {
fstype = signatures[i].fstype; fstype = signatures[i].fstype;
break; break;
@ -1241,7 +1241,7 @@ FSType GParted_Core::detect_filesystem_internal(const Glib::ustring& path, Byte_
FSType GParted_Core::detect_filesystem(const PedDevice *lp_device, const PedPartition *lp_partition, FSType GParted_Core::detect_filesystem(const PedDevice *lp_device, const PedPartition *lp_partition,
std::vector<Glib::ustring> &messages) std::vector<Glib::ustring> &messages)
{ {
g_assert(lp_device != NULL); // Bug: Not initialised by call to ped_device_get() or ped_device_get_next() g_assert(lp_device != nullptr); // Bug: Not initialised by call to ped_device_get() or ped_device_get_next()
Glib::ustring fsname = ""; Glib::ustring fsname = "";
Glib::ustring path; Glib::ustring path;
@ -1382,7 +1382,7 @@ FSType GParted_Core::detect_filesystem(const PedDevice *lp_device, const PedPart
void GParted_Core::read_label( Partition & partition ) void GParted_Core::read_label( Partition & partition )
{ {
FileSystem* p_filesystem = NULL; FileSystem* p_filesystem = nullptr;
switch (get_fs(partition.fstype).read_label) switch (get_fs(partition.fstype).read_label)
{ {
case FS::EXTERNAL: case FS::EXTERNAL:
@ -1398,7 +1398,7 @@ void GParted_Core::read_label( Partition & partition )
void GParted_Core::read_uuid( Partition & partition ) void GParted_Core::read_uuid( Partition & partition )
{ {
FileSystem* p_filesystem = NULL; FileSystem* p_filesystem = nullptr;
switch (get_fs(partition.fstype).read_uuid) switch (get_fs(partition.fstype).read_uuid)
{ {
case FS::EXTERNAL: case FS::EXTERNAL:
@ -1574,7 +1574,7 @@ bool GParted_Core::set_mountpoints_helper( Partition & partition, const Glib::us
// Report whether the partition is busy (mounted/active) // Report whether the partition is busy (mounted/active)
bool GParted_Core::is_busy(const Glib::ustring& device_path, FSType fstype, const Glib::ustring& partition_path) bool GParted_Core::is_busy(const Glib::ustring& device_path, FSType fstype, const Glib::ustring& partition_path)
{ {
FileSystem * p_filesystem = NULL ; FileSystem* p_filesystem = nullptr;
bool busy = false ; bool busy = false ;
if ( supported_filesystem( fstype ) ) if ( supported_filesystem( fstype ) )
@ -1620,7 +1620,7 @@ void GParted_Core::set_used_sectors( Partition & partition, PedDisk* lp_disk )
{ {
if (supported_filesystem(partition.fstype)) if (supported_filesystem(partition.fstype))
{ {
FileSystem* p_filesystem = NULL; FileSystem* p_filesystem = nullptr;
if ( partition.busy ) if ( partition.busy )
{ {
switch(get_fs(partition.fstype).online_read) switch(get_fs(partition.fstype).online_read)
@ -1738,8 +1738,8 @@ void GParted_Core::mounted_fs_set_used_sectors( Partition & partition )
#ifdef HAVE_LIBPARTED_FS_RESIZE #ifdef HAVE_LIBPARTED_FS_RESIZE
void GParted_Core::LP_set_used_sectors( Partition & partition, PedDisk* lp_disk ) void GParted_Core::LP_set_used_sectors( Partition & partition, PedDisk* lp_disk )
{ {
PedFileSystem *fs = NULL; PedFileSystem* fs = nullptr;
PedConstraint *constraint = NULL; PedConstraint* constraint = nullptr;
if ( lp_disk ) if ( lp_disk )
{ {
@ -1815,13 +1815,13 @@ bool GParted_Core::create_partition( Partition & new_partition, OperationDetail
operationdetail .add_child( OperationDetail( _("create empty partition") ) ) ; operationdetail .add_child( OperationDetail( _("create empty partition") ) ) ;
new_partition .partition_number = 0 ; new_partition .partition_number = 0 ;
PedDevice* lp_device = NULL ; PedDevice* lp_device = nullptr;
PedDisk* lp_disk = NULL ; PedDisk* lp_disk = nullptr;
if ( get_device_and_disk( new_partition .device_path, lp_device, lp_disk ) ) if ( get_device_and_disk( new_partition .device_path, lp_device, lp_disk ) )
{ {
PedPartitionType type; PedPartitionType type;
PedConstraint *constraint = NULL ; PedConstraint* constraint = nullptr;
PedFileSystemType* fs_type = NULL ; PedFileSystemType* fs_type = nullptr;
//create new partition //create new partition
switch ( new_partition .type ) switch ( new_partition .type )
@ -1935,7 +1935,7 @@ bool GParted_Core::create_filesystem( const Partition & partition, OperationDeta
Utils::get_filesystem_string(partition.fstype)))); Utils::get_filesystem_string(partition.fstype))));
bool succes = false ; bool succes = false ;
FileSystem* p_filesystem = NULL ; FileSystem* p_filesystem = nullptr;
switch (get_fs(partition.fstype).create) switch (get_fs(partition.fstype).create)
{ {
case FS::NONE: case FS::NONE:
@ -1982,8 +1982,8 @@ bool GParted_Core::delete_partition( const Partition & partition, OperationDetai
operationdetail .add_child( OperationDetail( _("delete partition") ) ) ; operationdetail .add_child( OperationDetail( _("delete partition") ) ) ;
bool succes = false ; bool succes = false ;
PedDevice* lp_device = NULL ; PedDevice* lp_device = nullptr;
PedDisk* lp_disk = NULL ; PedDisk* lp_disk = nullptr;
if ( get_device_and_disk( partition .device_path, lp_device, lp_disk ) ) if ( get_device_and_disk( partition .device_path, lp_device, lp_disk ) )
{ {
PedPartition* lp_partition = get_lp_partition( lp_disk, partition ); PedPartition* lp_partition = get_lp_partition( lp_disk, partition );
@ -1998,8 +1998,8 @@ bool GParted_Core::delete_partition( const Partition & partition, OperationDetai
DMRaid dmraid ; DMRaid dmraid ;
if ( succes && dmraid .is_dmraid_device( partition .device_path ) ) if ( succes && dmraid .is_dmraid_device( partition .device_path ) )
{ {
PedDevice* lp_device = NULL ; PedDevice* lp_device = nullptr;
PedDisk* lp_disk = NULL ; PedDisk* lp_disk = nullptr;
//Open disk handle before and close after to prevent application crash. //Open disk handle before and close after to prevent application crash.
if ( get_device_and_disk( partition .device_path, lp_device, lp_disk ) ) if ( get_device_and_disk( partition .device_path, lp_device, lp_disk ) )
{ {
@ -2029,7 +2029,7 @@ bool GParted_Core::remove_filesystem( const Partition & partition, OperationDeta
} }
bool success = true ; bool success = true ;
FileSystem* p_filesystem = NULL ; FileSystem* p_filesystem = nullptr;
switch (get_fs(partition.fstype ).remove) switch (get_fs(partition.fstype ).remove)
{ {
@ -2071,7 +2071,7 @@ bool GParted_Core::label_filesystem( const Partition & partition, OperationDetai
} }
bool succes = false ; bool succes = false ;
FileSystem* p_filesystem = NULL ; FileSystem* p_filesystem = nullptr;
const FS& fs_cap = get_fs(partition.fstype); const FS& fs_cap = get_fs(partition.fstype);
FS::Support support = (partition.busy) ? fs_cap.online_write_label : fs_cap.write_label; FS::Support support = (partition.busy) ? fs_cap.online_write_label : fs_cap.write_label;
switch (support) switch (support)
@ -2100,8 +2100,8 @@ bool GParted_Core::name_partition( const Partition & partition, OperationDetail
partition.name, partition.get_path() ) ) ); partition.name, partition.get_path() ) ) );
bool success = false; bool success = false;
PedDevice *lp_device = NULL; PedDevice* lp_device = nullptr;
PedDisk *lp_disk = NULL; PedDisk* lp_disk = nullptr;
if ( get_device_and_disk( partition.device_path, lp_device, lp_disk ) ) if ( get_device_and_disk( partition.device_path, lp_device, lp_disk ) )
{ {
PedPartition *lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition.get_sector() ); PedPartition *lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition.get_sector() );
@ -2139,7 +2139,7 @@ bool GParted_Core::change_filesystem_uuid( const Partition & partition, Operatio
} }
bool succes = false ; bool succes = false ;
FileSystem* p_filesystem = NULL ; FileSystem* p_filesystem = nullptr;
switch (get_fs(partition.fstype).write_uuid) switch (get_fs(partition.fstype).write_uuid)
{ {
case FS::EXTERNAL: case FS::EXTERNAL:
@ -2175,7 +2175,7 @@ bool GParted_Core::resize_move( const Partition & partition_old,
{ {
return move( partition_old, partition_new, operationdetail ); return move( partition_old, partition_new, operationdetail );
} }
Partition * temp = NULL; Partition* temp = nullptr;
if ( partition_new .get_sector_length() > partition_old .get_sector_length() ) if ( partition_new .get_sector_length() > partition_old .get_sector_length() )
{ {
//first move, then grow. Since old.length < new.length and new.start is valid, temp is valid. //first move, then grow. Since old.length < new.length and new.start is valid, temp is valid.
@ -2197,7 +2197,7 @@ bool GParted_Core::resize_move( const Partition & partition_old,
success = resize_move( *temp, partition_new, operationdetail ); success = resize_move( *temp, partition_new, operationdetail );
delete temp; delete temp;
temp = NULL; temp = nullptr;
return success; return success;
} }
@ -2264,7 +2264,7 @@ bool GParted_Core::move( const Partition & partition_old,
} }
delete partition_restore; delete partition_restore;
partition_restore = NULL; partition_restore = nullptr;
} }
else else
{ {
@ -2280,7 +2280,7 @@ bool GParted_Core::move( const Partition & partition_old,
} }
delete partition_all_space; delete partition_all_space;
partition_all_space = NULL; partition_all_space = nullptr;
if ( ! success ) if ( ! success )
return false; return false;
@ -2313,7 +2313,7 @@ bool GParted_Core::move_filesystem( const Partition & partition_old,
} }
bool succes = false ; bool succes = false ;
FileSystem* p_filesystem = NULL ; FileSystem* p_filesystem = nullptr;
Sector total_done = 0; Sector total_done = 0;
switch (get_fs(partition_old.fstype).move) switch (get_fs(partition_old.fstype).move)
{ {
@ -2373,12 +2373,12 @@ bool GParted_Core::resize_move_filesystem_using_libparted( const Partition & par
operationdetail .add_child( OperationDetail( _("using libparted"), STATUS_NONE ) ) ; operationdetail .add_child( OperationDetail( _("using libparted"), STATUS_NONE ) ) ;
bool return_value = false ; bool return_value = false ;
PedDevice* lp_device = NULL ; PedDevice* lp_device = nullptr;
PedDisk* lp_disk = NULL ; PedDisk* lp_disk = nullptr;
if ( get_device_and_disk( partition_old .device_path, lp_device, lp_disk ) ) if ( get_device_and_disk( partition_old .device_path, lp_device, lp_disk ) )
{ {
PedFileSystem * fs = NULL ; PedFileSystem* fs = nullptr;
PedGeometry * lp_geom = NULL ; PedGeometry* lp_geom = nullptr;
lp_geom = ped_geometry_new( lp_device, lp_geom = ped_geometry_new( lp_device,
partition_old .sector_start, partition_old .sector_start,
@ -2388,7 +2388,7 @@ bool GParted_Core::resize_move_filesystem_using_libparted( const Partition & par
fs = ped_file_system_open( lp_geom ); fs = ped_file_system_open( lp_geom );
ped_geometry_destroy( lp_geom ); ped_geometry_destroy( lp_geom );
lp_geom = NULL; lp_geom = nullptr;
if ( fs ) if ( fs )
{ {
@ -2426,8 +2426,8 @@ void GParted_Core::thread_lp_ped_file_system_resize( PedFileSystem * fs,
PedGeometry * lp_geom, PedGeometry * lp_geom,
bool * return_value ) bool * return_value )
{ {
*return_value = ped_file_system_resize( fs, lp_geom, NULL ); *return_value = ped_file_system_resize(fs, lp_geom, nullptr);
g_idle_add( (GSourceFunc)_mainquit, NULL ); g_idle_add((GSourceFunc)_mainquit, nullptr);
} }
#endif #endif
@ -2729,9 +2729,9 @@ bool GParted_Core::resize_move_partition( const Partition & partition_old,
rollback_success = rollback_success && update_dmraid_entry( *partition_restore, operationdetail ); rollback_success = rollback_success && update_dmraid_entry( *partition_restore, operationdetail );
delete partition_restore; delete partition_restore;
partition_restore = NULL; partition_restore = nullptr;
delete partition_intersection; delete partition_intersection;
partition_intersection = NULL; partition_intersection = nullptr;
operationdetail.get_last_child().set_success_and_capture_errors( rollback_success ); operationdetail.get_last_child().set_success_and_capture_errors( rollback_success );
} }
@ -2745,14 +2745,14 @@ bool GParted_Core::resize_move_partition_implement( const Partition & partition_
Sector & new_end ) Sector & new_end )
{ {
bool success = false; bool success = false;
PedDevice *lp_device = NULL; PedDevice* lp_device = nullptr;
PedDisk *lp_disk = NULL; PedDisk* lp_disk = nullptr;
if ( get_device_and_disk( partition_old.device_path, lp_device, lp_disk ) ) if ( get_device_and_disk( partition_old.device_path, lp_device, lp_disk ) )
{ {
PedPartition *lp_partition = get_lp_partition( lp_disk, partition_old ); PedPartition *lp_partition = get_lp_partition( lp_disk, partition_old );
if ( lp_partition ) if ( lp_partition )
{ {
PedConstraint *constraint = NULL; PedConstraint* constraint = nullptr;
if ( partition_new.alignment == ALIGN_STRICT || if ( partition_new.alignment == ALIGN_STRICT ||
partition_new.alignment == ALIGN_MEBIBYTE || partition_new.alignment == ALIGN_MEBIBYTE ||
partition_new.strict_start ) partition_new.strict_start )
@ -2969,7 +2969,7 @@ bool GParted_Core::resize_filesystem_implement( const Partition & partition_old,
action = ( partition_old.busy ) ? fs_cap.online_shrink : fs_cap.shrink; action = ( partition_old.busy ) ? fs_cap.online_shrink : fs_cap.shrink;
} }
bool success = false; bool success = false;
FileSystem* p_filesystem = NULL; FileSystem* p_filesystem = nullptr;
switch ( action ) switch ( action )
{ {
case FS::NONE: case FS::NONE:
@ -3078,7 +3078,7 @@ bool GParted_Core::copy_filesystem( const Partition & partition_src,
partition_dst.get_path() ) ) ); partition_dst.get_path() ) ) );
bool success = false; bool success = false;
FileSystem* p_filesystem = NULL; FileSystem* p_filesystem = nullptr;
switch (get_fs(partition_dst.fstype).copy) switch (get_fs(partition_dst.fstype).copy)
{ {
case FS::GPARTED: case FS::GPARTED:
@ -3306,8 +3306,8 @@ void GParted_Core::rollback_move_filesystem( const Partition & partition_src,
delete temp_src; delete temp_src;
delete temp_dst; delete temp_dst;
temp_src = NULL; temp_src = nullptr;
temp_dst = NULL; temp_dst = nullptr;
} }
} }
@ -3332,7 +3332,7 @@ bool GParted_Core::check_repair_filesystem( const Partition & partition, Operati
partition .get_path() ) ) ) ; partition .get_path() ) ) ) ;
bool succes = false ; bool succes = false ;
FileSystem* p_filesystem = NULL ; FileSystem* p_filesystem = nullptr;
switch (get_fs(partition.fstype).check) switch (get_fs(partition.fstype).check)
{ {
case FS::NONE: case FS::NONE:
@ -3380,7 +3380,7 @@ bool GParted_Core::check_repair_maximize( const Partition & partition,
temp_offline->busy = false; temp_offline->busy = false;
bool success = maximize_encryption( *temp_offline, operationdetail ); bool success = maximize_encryption( *temp_offline, operationdetail );
delete temp_offline; delete temp_offline;
temp_offline = NULL; temp_offline = nullptr;
if ( ! success ) if ( ! success )
return false; return false;
@ -3408,8 +3408,8 @@ bool GParted_Core::set_partition_type( const Partition & partition, OperationDet
bool return_value = false ; bool return_value = false ;
PedDevice* lp_device = NULL ; PedDevice* lp_device = nullptr;
PedDisk* lp_disk = NULL ; PedDisk* lp_disk = nullptr;
if ( get_device_and_disk( partition .device_path, lp_device, lp_disk ) ) if ( get_device_and_disk( partition .device_path, lp_device, lp_disk ) )
{ {
PedPartition* lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition.get_sector() ); PedPartition* lp_partition = ped_disk_get_partition_by_sector( lp_disk, partition.get_sector() );
@ -3420,7 +3420,7 @@ bool GParted_Core::set_partition_type( const Partition & partition, OperationDet
// Lookup libparted file system type using GParted's name, as most // Lookup libparted file system type using GParted's name, as most
// match. Exclude cleared as the name won't be recognised by // match. Exclude cleared as the name won't be recognised by
// libparted and get_filesystem_string() has also translated it. // libparted and get_filesystem_string() has also translated it.
PedFileSystemType *lp_fs_type = NULL; PedFileSystemType* lp_fs_type = nullptr;
if (partition.fstype != FS_CLEARED) if (partition.fstype != FS_CLEARED)
lp_fs_type = ped_file_system_type_get(fs_type.c_str()); lp_fs_type = ped_file_system_type_get(fs_type.c_str());
@ -3503,8 +3503,8 @@ bool GParted_Core::calibrate_partition( Partition & partition, OperationDetail &
operationdetail.add_child( OperationDetail( Glib::ustring::compose( _("calibrate %1"), curr_path ) ) ); operationdetail.add_child( OperationDetail( Glib::ustring::compose( _("calibrate %1"), curr_path ) ) );
bool success = false; bool success = false;
PedDevice* lp_device = NULL ; PedDevice* lp_device = nullptr;
PedDisk* lp_disk = NULL ; PedDisk* lp_disk = nullptr;
if ( get_device( partition.device_path, lp_device ) ) if ( get_device( partition.device_path, lp_device ) )
{ {
if ( partition.type == TYPE_UNPARTITIONED ) if ( partition.type == TYPE_UNPARTITIONED )
@ -3612,14 +3612,14 @@ bool GParted_Core::calculate_exact_geom( const Partition & partition_old,
FONT_ITALIC ) ) ; FONT_ITALIC ) ) ;
bool succes = false ; bool succes = false ;
PedDevice* lp_device = NULL ; PedDevice* lp_device = nullptr;
PedDisk* lp_disk = NULL ; PedDisk* lp_disk = nullptr;
if ( get_device_and_disk( partition_old .device_path, lp_device, lp_disk ) ) if ( get_device_and_disk( partition_old .device_path, lp_device, lp_disk ) )
{ {
PedPartition* lp_partition = get_lp_partition( lp_disk, partition_old ); PedPartition* lp_partition = get_lp_partition( lp_disk, partition_old );
if ( lp_partition ) if ( lp_partition )
{ {
PedConstraint *constraint = NULL ; PedConstraint* constraint = nullptr;
constraint = ped_constraint_any( lp_device ) ; constraint = ped_constraint_any( lp_device ) ;
if ( constraint ) if ( constraint )
@ -3673,7 +3673,7 @@ bool GParted_Core::update_dmraid_entry( const Partition & partition, OperationDe
DMRaid dmraid; DMRaid dmraid;
if ( dmraid.is_dmraid_device( partition.device_path ) ) if ( dmraid.is_dmraid_device( partition.device_path ) )
{ {
PedDevice *lp_device = NULL; PedDevice* lp_device = nullptr;
PedDisk *lp_disk; PedDisk *lp_disk;
// Open disk handle before and close after to prevent application crash. // Open disk handle before and close after to prevent application crash.
if ( get_device_and_disk( partition.device_path, lp_device, lp_disk ) ) if ( get_device_and_disk( partition.device_path, lp_device, lp_disk ) )
@ -3696,7 +3696,7 @@ FileSystem * GParted_Core::get_filesystem_object( FSType fstype )
// Return true for file systems with an implementation class, false otherwise // Return true for file systems with an implementation class, false otherwise
bool GParted_Core::supported_filesystem( FSType fstype ) bool GParted_Core::supported_filesystem( FSType fstype )
{ {
return supported_filesystems->get_fs_object(fstype) != NULL; return supported_filesystems->get_fs_object(fstype) != nullptr;
} }
@ -3704,7 +3704,7 @@ FS_Limits GParted_Core::get_filesystem_limits( FSType fstype, const Partition &
{ {
FileSystem* p_filesystem = supported_filesystems->get_fs_object(fstype); FileSystem* p_filesystem = supported_filesystems->get_fs_object(fstype);
FS_Limits fs_limits; FS_Limits fs_limits;
if ( p_filesystem != NULL ) if (p_filesystem != nullptr)
fs_limits = p_filesystem->get_filesystem_limits( partition ); fs_limits = p_filesystem->get_filesystem_limits( partition );
return fs_limits; return fs_limits;
} }
@ -3739,13 +3739,13 @@ bool GParted_Core::erase_filesystem_signatures( const Partition & partition, Ope
//Get device, disk & partition and open the device. Allocate buffer and fill with //Get device, disk & partition and open the device. Allocate buffer and fill with
// zeros. Buffer size is the greater of 4 KiB and the sector size. // zeros. Buffer size is the greater of 4 KiB and the sector size.
PedDevice* lp_device = NULL ; PedDevice* lp_device = nullptr;
PedDisk* lp_disk = NULL ; PedDisk* lp_disk = nullptr;
PedPartition* lp_partition = NULL ; PedPartition* lp_partition = nullptr;
PedGeometry *lp_geom = NULL; PedGeometry* lp_geom = nullptr;
bool device_is_open = false ; bool device_is_open = false ;
Byte_Value bufsize = 4LL * KIBIBYTE ; Byte_Value bufsize = 4LL * KIBIBYTE ;
char * buf = NULL ; char* buf = nullptr;
if ( get_device( partition.device_path, lp_device ) ) if ( get_device( partition.device_path, lp_device ) )
{ {
if ( partition.type == TYPE_UNPARTITIONED ) if ( partition.type == TYPE_UNPARTITIONED )
@ -3763,7 +3763,7 @@ bool GParted_Core::erase_filesystem_signatures( const Partition & partition, Ope
lp_geom = ped_geometry_duplicate(&lp_partition->geom); lp_geom = ped_geometry_duplicate(&lp_partition->geom);
} }
if (lp_geom != NULL && ped_device_open(lp_device)) if (lp_geom != nullptr && ped_device_open(lp_device))
{ {
device_is_open = true ; device_is_open = true ;
@ -3901,7 +3901,7 @@ bool GParted_Core::erase_filesystem_signatures( const Partition & partition, Ope
} }
if ( buf ) if ( buf )
free( buf ) ; free( buf ) ;
if (lp_geom != NULL) if (lp_geom != nullptr)
ped_geometry_destroy(lp_geom); ped_geometry_destroy(lp_geom);
//Linux kernel doesn't maintain buffer cache coherency between the whole disk //Linux kernel doesn't maintain buffer cache coherency between the whole disk
@ -4047,7 +4047,7 @@ void GParted_Core::capture_libparted_messages( OperationDetail & operationdetail
bool GParted_Core::useable_device(const PedDevice* lp_device) bool GParted_Core::useable_device(const PedDevice* lp_device)
{ {
g_assert( lp_device != NULL ); // Bug: Not initialised by call to ped_device_get() or ped_device_get_next() g_assert(lp_device != nullptr); // Bug: Not initialised by call to ped_device_get() or ped_device_get_next()
char * buf = static_cast<char *>( malloc( lp_device->sector_size ) ); char * buf = static_cast<char *>( malloc( lp_device->sector_size ) );
if ( ! buf ) if ( ! buf )
@ -4119,7 +4119,7 @@ bool GParted_Core::get_device( const Glib::ustring & device_path, PedDevice *& l
bool GParted_Core::get_disk(PedDevice *lp_device, PedDisk*& lp_disk) bool GParted_Core::get_disk(PedDevice *lp_device, PedDisk*& lp_disk)
{ {
g_assert(lp_device != NULL); // Bug: Not initialised by call to ped_device_get() or ped_device_get_next() g_assert(lp_device != nullptr); // Bug: Not initialised by call to ped_device_get() or ped_device_get_next()
lp_disk = ped_disk_new(lp_device); lp_disk = ped_disk_new(lp_device);
@ -4129,7 +4129,7 @@ bool GParted_Core::get_disk(PedDevice *lp_device, PedDisk*& lp_disk)
// /dev/PTN entries don't exist. // /dev/PTN entries don't exist.
settle_device(SETTLE_DEVICE_PROBE_MAX_WAIT_SECONDS); settle_device(SETTLE_DEVICE_PROBE_MAX_WAIT_SECONDS);
return (lp_disk != NULL); return (lp_disk != nullptr);
} }
@ -4152,11 +4152,11 @@ void GParted_Core::destroy_device_and_disk( PedDevice*& lp_device, PedDisk*& lp_
{ {
if ( lp_disk ) if ( lp_disk )
ped_disk_destroy( lp_disk ) ; ped_disk_destroy( lp_disk ) ;
lp_disk = NULL ; lp_disk = nullptr;
if ( lp_device ) if ( lp_device )
ped_device_destroy( lp_device ) ; ped_device_destroy( lp_device ) ;
lp_device = NULL ; lp_device = nullptr;
} }
bool GParted_Core::commit( PedDisk* lp_disk ) bool GParted_Core::commit( PedDisk* lp_disk )
@ -4324,7 +4324,7 @@ PedExceptionOption GParted_Core::ped_exception_handler( PedException * e )
GParted_Core::~GParted_Core() GParted_Core::~GParted_Core()
{ {
delete supported_filesystems; delete supported_filesystems;
supported_filesystems = NULL; supported_filesystems = nullptr;
} }

View File

@ -153,11 +153,11 @@ bool Mount_Info::is_dev_mounted_at(const Glib::ustring& path, const Glib::ustrin
void Mount_Info::read_mountpoints_from_file( const Glib::ustring & filename, MountMapping & map ) void Mount_Info::read_mountpoints_from_file( const Glib::ustring & filename, MountMapping & map )
{ {
FILE* fp = setmntent( filename .c_str(), "r" ); FILE* fp = setmntent( filename .c_str(), "r" );
if ( fp == NULL ) if (fp == nullptr)
return; return;
struct mntent* p = NULL; struct mntent* p = nullptr;
while ( ( p = getmntent( fp ) ) != NULL ) while ((p = getmntent(fp)) != nullptr)
{ {
Glib::ustring node = lookup_uuid_or_label(p->mnt_fsname); Glib::ustring node = lookup_uuid_or_label(p->mnt_fsname);
if (node.empty()) if (node.empty())

View File

@ -29,35 +29,35 @@ Operation::Operation()
Partition & Operation::get_partition_original() Partition & Operation::get_partition_original()
{ {
g_assert( partition_original != NULL ); // Bug: Not initialised by derived Operation*() constructor or reset later g_assert(partition_original != nullptr); // Bug: Not initialised by derived Operation*() constructor or reset later
return *partition_original; return *partition_original;
} }
const Partition & Operation::get_partition_original() const const Partition & Operation::get_partition_original() const
{ {
g_assert( partition_original != NULL ); // Bug: Not initialised by derived Operation*() constructor or reset later g_assert(partition_original != nullptr); // Bug: Not initialised by derived Operation*() constructor or reset later
return *partition_original; return *partition_original;
} }
Partition & Operation::get_partition_new() Partition & Operation::get_partition_new()
{ {
g_assert( partition_new != NULL ); // Bug: Not initialised by derived Operation*() constructor or reset later g_assert(partition_new != nullptr); // Bug: Not initialised by derived Operation*() constructor or reset later
return *partition_new; return *partition_new;
} }
const Partition & Operation::get_partition_new() const const Partition & Operation::get_partition_new() const
{ {
g_assert( partition_new != NULL ); // Bug: Not initialised by derived Operation*() constructor or reset later g_assert(partition_new != nullptr); // Bug: Not initialised by derived Operation*() constructor or reset later
return *partition_new; return *partition_new;
} }
int Operation::find_index_original( const PartitionVector & partitions ) int Operation::find_index_original( const PartitionVector & partitions )
{ {
g_assert( partition_original != NULL ); // Bug: Not initialised by derived Operation*() constructor or reset later g_assert(partition_original != nullptr); // Bug: Not initialised by derived Operation*() constructor or reset later
for ( unsigned int t = 0 ; t < partitions .size() ; t++ ) for ( unsigned int t = 0 ; t < partitions .size() ; t++ )
if ( partition_original->sector_start >= partitions[t].sector_start && if ( partition_original->sector_start >= partitions[t].sector_start &&
@ -71,7 +71,7 @@ int Operation::find_index_original( const PartitionVector & partitions )
// this->partition_new. Return vector index or -1 when no match found. // this->partition_new. Return vector index or -1 when no match found.
int Operation::find_index_new( const PartitionVector & partitions ) int Operation::find_index_new( const PartitionVector & partitions )
{ {
g_assert( partition_new != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_new != nullptr); // Bug: Not initialised by constructor or reset later
for ( unsigned int i = 0 ; i < partitions.size() ; i ++ ) for ( unsigned int i = 0 ; i < partitions.size() ; i ++ )
if ( partition_new->sector_start >= partitions[i].sector_start && if ( partition_new->sector_start >= partitions[i].sector_start &&
@ -93,8 +93,8 @@ void Operation::insert_unallocated( PartitionVector & partitions,
// it with this operation's new partition. // it with this operation's new partition.
void Operation::substitute_new( PartitionVector & partitions ) void Operation::substitute_new( PartitionVector & partitions )
{ {
g_assert( partition_original != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_original != nullptr); // Bug: Not initialised by constructor or reset later
g_assert( partition_new != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_new != nullptr); // Bug: Not initialised by constructor or reset later
int index_extended; int index_extended;
int index; int index;
@ -130,7 +130,7 @@ void Operation::insert_new( PartitionVector & partitions )
// their operations to the disk graphic. Hence their use of, // their operations to the disk graphic. Hence their use of,
// find_index_original(). // find_index_original().
g_assert( partition_new != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_new != nullptr); // Bug: Not initialised by constructor or reset later
int index_extended; int index_extended;
int index; int index;

View File

@ -37,8 +37,8 @@ OperationChangeUUID::~OperationChangeUUID()
{ {
delete partition_original; delete partition_original;
delete partition_new; delete partition_new;
partition_original = NULL; partition_original = nullptr;
partition_new = NULL; partition_new = nullptr;
} }
void OperationChangeUUID::apply_to_visual( PartitionVector & partitions ) void OperationChangeUUID::apply_to_visual( PartitionVector & partitions )
@ -48,7 +48,7 @@ void OperationChangeUUID::apply_to_visual( PartitionVector & partitions )
void OperationChangeUUID::create_description() void OperationChangeUUID::create_description()
{ {
g_assert( partition_new != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_new != nullptr); // Bug: Not initialised by constructor or reset later
if ( partition_new->get_filesystem_partition().uuid == UUID_RANDOM_NTFS_HALF ) if ( partition_new->get_filesystem_partition().uuid == UUID_RANDOM_NTFS_HALF )
{ {
@ -68,7 +68,7 @@ void OperationChangeUUID::create_description()
bool OperationChangeUUID::merge_operations( const Operation & candidate ) bool OperationChangeUUID::merge_operations( const Operation & candidate )
{ {
g_assert( partition_new != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_new != nullptr); // Bug: Not initialised by constructor or reset later
if ( candidate.type == OPERATION_CHANGE_UUID && if ( candidate.type == OPERATION_CHANGE_UUID &&
*partition_new == candidate.get_partition_original() ) *partition_new == candidate.get_partition_original() )

View File

@ -34,8 +34,8 @@ OperationCheck::~OperationCheck()
{ {
delete partition_original; delete partition_original;
delete partition_new; delete partition_new;
partition_original = NULL; partition_original = nullptr;
partition_new = NULL; partition_new = nullptr;
} }
void OperationCheck::apply_to_visual( PartitionVector & partitions ) void OperationCheck::apply_to_visual( PartitionVector & partitions )
@ -44,7 +44,7 @@ void OperationCheck::apply_to_visual( PartitionVector & partitions )
void OperationCheck::create_description() void OperationCheck::create_description()
{ {
g_assert( partition_original != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_original != nullptr); // Bug: Not initialised by constructor or reset later
/*TO TRANSLATORS: looks like Check and repair file system (ext3) on /dev/hda4 */ /*TO TRANSLATORS: looks like Check and repair file system (ext3) on /dev/hda4 */
description = Glib::ustring::compose( _("Check and repair file system (%1) on %2"), description = Glib::ustring::compose( _("Check and repair file system (%1) on %2"),
@ -54,7 +54,7 @@ void OperationCheck::create_description()
bool OperationCheck::merge_operations( const Operation & candidate ) bool OperationCheck::merge_operations( const Operation & candidate )
{ {
g_assert( partition_original != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_original != nullptr); // Bug: Not initialised by constructor or reset later
if ( candidate.type == OPERATION_CHECK && if ( candidate.type == OPERATION_CHECK &&
*partition_original == candidate.get_partition_original() ) *partition_original == candidate.get_partition_original() )

View File

@ -40,28 +40,28 @@ OperationCopy::~OperationCopy()
delete partition_original; delete partition_original;
delete partition_new; delete partition_new;
delete partition_copied; delete partition_copied;
partition_original = NULL; partition_original = nullptr;
partition_new = NULL; partition_new = nullptr;
partition_copied = NULL; partition_copied = nullptr;
} }
Partition & OperationCopy::get_partition_copied() Partition & OperationCopy::get_partition_copied()
{ {
g_assert( partition_copied != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_copied != nullptr); // Bug: Not initialised by constructor or reset later
return *partition_copied; return *partition_copied;
} }
const Partition & OperationCopy::get_partition_copied() const const Partition & OperationCopy::get_partition_copied() const
{ {
g_assert( partition_copied != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_copied != nullptr); // Bug: Not initialised by constructor or reset later
return *partition_copied; return *partition_copied;
} }
void OperationCopy::apply_to_visual( PartitionVector & partitions ) void OperationCopy::apply_to_visual( PartitionVector & partitions )
{ {
g_assert( partition_original != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_original != nullptr); // Bug: Not initialised by constructor or reset later
if ( partition_original->type == TYPE_UNALLOCATED ) if ( partition_original->type == TYPE_UNALLOCATED )
// Paste into unallocated space creating new partition // Paste into unallocated space creating new partition
@ -73,9 +73,9 @@ void OperationCopy::apply_to_visual( PartitionVector & partitions )
void OperationCopy::create_description() void OperationCopy::create_description()
{ {
g_assert( partition_original != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_original != nullptr); // Bug: Not initialised by constructor or reset later
g_assert( partition_new != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_new != nullptr); // Bug: Not initialised by constructor or reset later
g_assert( partition_copied != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_copied != nullptr); // Bug: Not initialised by constructor or reset later
if ( partition_original->type == TYPE_UNALLOCATED ) if ( partition_original->type == TYPE_UNALLOCATED )
{ {

View File

@ -39,8 +39,8 @@ OperationCreate::~OperationCreate()
{ {
delete partition_original; delete partition_original;
delete partition_new; delete partition_new;
partition_original = NULL; partition_original = nullptr;
partition_new = NULL; partition_new = nullptr;
} }
void OperationCreate::apply_to_visual( PartitionVector & partitions ) void OperationCreate::apply_to_visual( PartitionVector & partitions )
@ -50,7 +50,7 @@ void OperationCreate::apply_to_visual( PartitionVector & partitions )
void OperationCreate::create_description() void OperationCreate::create_description()
{ {
g_assert( partition_new != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_new != nullptr); // Bug: Not initialised by constructor or reset later
switch( partition_new->type ) switch( partition_new->type )
{ {
@ -79,7 +79,7 @@ void OperationCreate::create_description()
bool OperationCreate::merge_operations( const Operation & candidate ) bool OperationCreate::merge_operations( const Operation & candidate )
{ {
g_assert( partition_new != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_new != nullptr); // Bug: Not initialised by constructor or reset later
if ( candidate.type == OPERATION_FORMAT && if ( candidate.type == OPERATION_FORMAT &&
candidate.get_partition_original().status == STAT_NEW && candidate.get_partition_original().status == STAT_NEW &&

View File

@ -33,7 +33,7 @@ OperationDelete::OperationDelete( const Device & device, const Partition & parti
OperationDelete::~OperationDelete() OperationDelete::~OperationDelete()
{ {
delete partition_original; delete partition_original;
partition_original = NULL; partition_original = nullptr;
} }
Partition & OperationDelete::get_partition_new() Partition & OperationDelete::get_partition_new()
@ -54,7 +54,7 @@ const Partition & OperationDelete::get_partition_new() const
void OperationDelete::apply_to_visual( PartitionVector & partitions ) void OperationDelete::apply_to_visual( PartitionVector & partitions )
{ {
g_assert( partition_original != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_original != nullptr); // Bug: Not initialised by constructor or reset later
int index_extended; int index_extended;
int index; int index;
@ -103,7 +103,7 @@ void OperationDelete::apply_to_visual( PartitionVector & partitions )
void OperationDelete::create_description() void OperationDelete::create_description()
{ {
g_assert( partition_original != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_original != nullptr); // Bug: Not initialised by constructor or reset later
if ( partition_original->type == TYPE_LOGICAL ) if ( partition_original->type == TYPE_LOGICAL )
description = _("Logical Partition") ; description = _("Logical Partition") ;

View File

@ -90,13 +90,13 @@ void OperationDetail::set_status( OperationDetailStatus status )
{ {
case STATUS_EXECUTE: case STATUS_EXECUTE:
time_elapsed = -1 ; time_elapsed = -1 ;
time_start = std::time( NULL ) ; time_start = std::time(nullptr);
break ; break ;
case STATUS_ERROR: case STATUS_ERROR:
case STATUS_WARNING: case STATUS_WARNING:
case STATUS_SUCCESS: case STATUS_SUCCESS:
if( time_start != -1 ) if( time_start != -1 )
time_elapsed = std::time( NULL ) - time_start ; time_elapsed = std::time(nullptr) - time_start;
break ; break ;
default: default:

View File

@ -36,14 +36,14 @@ OperationFormat::~OperationFormat()
{ {
delete partition_original; delete partition_original;
delete partition_new; delete partition_new;
partition_original = NULL; partition_original = nullptr;
partition_new = NULL; partition_new = nullptr;
} }
void OperationFormat::apply_to_visual( PartitionVector & partitions ) void OperationFormat::apply_to_visual( PartitionVector & partitions )
{ {
g_assert( partition_original != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_original != nullptr); // Bug: Not initialised by constructor or reset later
g_assert( partition_new != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_new != nullptr); // Bug: Not initialised by constructor or reset later
if (partition_original->type == TYPE_UNPARTITIONED && partition_new->fstype == FS_CLEARED) if (partition_original->type == TYPE_UNPARTITIONED && partition_new->fstype == FS_CLEARED)
{ {
@ -68,8 +68,8 @@ void OperationFormat::apply_to_visual( PartitionVector & partitions )
void OperationFormat::create_description() void OperationFormat::create_description()
{ {
g_assert( partition_original != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_original != nullptr); // Bug: Not initialised by constructor or reset later
g_assert( partition_new != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_new != nullptr); // Bug: Not initialised by constructor or reset later
/*TO TRANSLATORS: looks like Format /dev/hda4 as linux-swap */ /*TO TRANSLATORS: looks like Format /dev/hda4 as linux-swap */
description = Glib::ustring::compose( _("Format %1 as %2"), description = Glib::ustring::compose( _("Format %1 as %2"),
@ -79,7 +79,7 @@ void OperationFormat::create_description()
bool OperationFormat::merge_operations( const Operation & candidate ) bool OperationFormat::merge_operations( const Operation & candidate )
{ {
g_assert( partition_new != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_new != nullptr); // Bug: Not initialised by constructor or reset later
if ( candidate.type == OPERATION_FORMAT && if ( candidate.type == OPERATION_FORMAT &&
*partition_new == candidate.get_partition_original() ) *partition_new == candidate.get_partition_original() )

View File

@ -36,8 +36,8 @@ OperationLabelFileSystem::~OperationLabelFileSystem()
{ {
delete partition_original; delete partition_original;
delete partition_new; delete partition_new;
partition_original = NULL; partition_original = nullptr;
partition_new = NULL; partition_new = nullptr;
} }
void OperationLabelFileSystem::apply_to_visual( PartitionVector & partitions ) void OperationLabelFileSystem::apply_to_visual( PartitionVector & partitions )
@ -47,7 +47,7 @@ void OperationLabelFileSystem::apply_to_visual( PartitionVector & partitions )
void OperationLabelFileSystem::create_description() void OperationLabelFileSystem::create_description()
{ {
g_assert( partition_new != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_new != nullptr); // Bug: Not initialised by constructor or reset later
if( partition_new->get_filesystem_partition().get_filesystem_label().empty() ) if( partition_new->get_filesystem_partition().get_filesystem_label().empty() )
{ {
@ -66,7 +66,7 @@ void OperationLabelFileSystem::create_description()
bool OperationLabelFileSystem::merge_operations( const Operation & candidate ) bool OperationLabelFileSystem::merge_operations( const Operation & candidate )
{ {
g_assert( partition_new != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_new != nullptr); // Bug: Not initialised by constructor or reset later
if ( candidate.type == OPERATION_LABEL_FILESYSTEM && if ( candidate.type == OPERATION_LABEL_FILESYSTEM &&
*partition_new == candidate.get_partition_original() ) *partition_new == candidate.get_partition_original() )

View File

@ -36,8 +36,8 @@ OperationNamePartition::~OperationNamePartition()
{ {
delete partition_original; delete partition_original;
delete partition_new; delete partition_new;
partition_original = NULL; partition_original = nullptr;
partition_new = NULL; partition_new = nullptr;
} }
void OperationNamePartition::apply_to_visual( PartitionVector & partitions ) void OperationNamePartition::apply_to_visual( PartitionVector & partitions )
@ -47,7 +47,7 @@ void OperationNamePartition::apply_to_visual( PartitionVector & partitions )
void OperationNamePartition::create_description() void OperationNamePartition::create_description()
{ {
g_assert( partition_new != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_new != nullptr); // Bug: Not initialised by constructor or reset later
if( partition_new->name.empty() ) if( partition_new->name.empty() )
{ {
@ -66,7 +66,7 @@ void OperationNamePartition::create_description()
bool OperationNamePartition::merge_operations( const Operation & candidate ) bool OperationNamePartition::merge_operations( const Operation & candidate )
{ {
g_assert( partition_new != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_new != nullptr); // Bug: Not initialised by constructor or reset later
if ( candidate.type == OPERATION_NAME_PARTITION && if ( candidate.type == OPERATION_NAME_PARTITION &&
*partition_new == candidate.get_partition_original() ) *partition_new == candidate.get_partition_original() )

View File

@ -37,13 +37,13 @@ OperationResizeMove::~OperationResizeMove()
{ {
delete partition_original; delete partition_original;
delete partition_new; delete partition_new;
partition_original = NULL; partition_original = nullptr;
partition_new = NULL; partition_new = nullptr;
} }
void OperationResizeMove::apply_to_visual( PartitionVector & partitions ) void OperationResizeMove::apply_to_visual( PartitionVector & partitions )
{ {
g_assert( partition_original != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_original != nullptr); // Bug: Not initialised by constructor or reset later
if ( partition_original->type == TYPE_EXTENDED ) if ( partition_original->type == TYPE_EXTENDED )
apply_extended_to_visual( partitions ) ; apply_extended_to_visual( partitions ) ;
@ -53,8 +53,8 @@ void OperationResizeMove::apply_to_visual( PartitionVector & partitions )
void OperationResizeMove::create_description() void OperationResizeMove::create_description()
{ {
g_assert( partition_original != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_original != nullptr); // Bug: Not initialised by constructor or reset later
g_assert( partition_new != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_new != nullptr); // Bug: Not initialised by constructor or reset later
//i'm not too happy with this, but i think it is the correct way from a i18n POV //i'm not too happy with this, but i think it is the correct way from a i18n POV
enum Action enum Action
@ -143,8 +143,8 @@ void OperationResizeMove::create_description()
void OperationResizeMove::apply_normal_to_visual( PartitionVector & partitions ) void OperationResizeMove::apply_normal_to_visual( PartitionVector & partitions )
{ {
g_assert( partition_original != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_original != nullptr); // Bug: Not initialised by constructor or reset later
g_assert( partition_new != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_new != nullptr); // Bug: Not initialised by constructor or reset later
int index_extended; int index_extended;
int index; int index;
@ -185,7 +185,7 @@ void OperationResizeMove::apply_normal_to_visual( PartitionVector & partitions )
void OperationResizeMove::apply_extended_to_visual( PartitionVector & partitions ) void OperationResizeMove::apply_extended_to_visual( PartitionVector & partitions )
{ {
g_assert( partition_new != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_new != nullptr); // Bug: Not initialised by constructor or reset later
int index_extended; int index_extended;
@ -239,7 +239,7 @@ void OperationResizeMove::remove_adjacent_unallocated( PartitionVector & partiti
bool OperationResizeMove::merge_operations( const Operation & candidate ) bool OperationResizeMove::merge_operations( const Operation & candidate )
{ {
g_assert( partition_new != NULL ); // Bug: Not initialised by constructor or reset later g_assert(partition_new != nullptr); // Bug: Not initialised by constructor or reset later
if ( candidate.type == OPERATION_RESIZE_MOVE && if ( candidate.type == OPERATION_RESIZE_MOVE &&
*partition_new == candidate.get_partition_original() ) *partition_new == candidate.get_partition_original() )

View File

@ -27,7 +27,7 @@ namespace GParted
// NOTE: As stated in Gtkmm3 documentation, slots can be shared for all model instances. // NOTE: As stated in Gtkmm3 documentation, slots can be shared for all model instances.
// See: Class Reference for Gtk::TreeModelColumn and Gtk::TreeModelColumnRecord. // See: Class Reference for Gtk::TreeModelColumn and Gtk::TreeModelColumnRecord.
// https://developer.gnome.org/gtkmm/3.22/classGtk_1_1TreeModelColumnRecord.html#details // https://developer.gnome.org/gtkmm/3.22/classGtk_1_1TreeModelColumnRecord.html#details
OptionStore::Slots *OptionStore::m_slots = NULL; OptionStore::Slots* OptionStore::m_slots = nullptr;
OptionStore_Item::OptionStore_Item(const Glib::RefPtr<OptionStore>& ref_model, OptionStore_Item::OptionStore_Item(const Glib::RefPtr<OptionStore>& ref_model,

View File

@ -85,11 +85,11 @@ const size_t ProtectedMemSize = 4096;
PWStore::PWStore() PWStore::PWStore()
{ {
// MAP_ANONYMOUS also ensures RAM is zero initialised. // MAP_ANONYMOUS also ensures RAM is zero initialised.
protected_mem = (char *) mmap( NULL, ProtectedMemSize, PROT_READ|PROT_WRITE, protected_mem = (char*) mmap(nullptr, ProtectedMemSize, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS|MAP_LOCKED, -1, 0 ); MAP_PRIVATE|MAP_ANONYMOUS|MAP_LOCKED, -1, 0);
if ( protected_mem == MAP_FAILED ) if ( protected_mem == MAP_FAILED )
{ {
protected_mem = NULL; protected_mem = nullptr;
std::cerr << "No locked virtual memory for password RAM store" << std::endl; std::cerr << "No locked virtual memory for password RAM store" << std::endl;
} }
} }
@ -97,13 +97,13 @@ PWStore::PWStore()
PWStore::~PWStore() PWStore::~PWStore()
{ {
erase_all(); erase_all();
if ( protected_mem != NULL ) if (protected_mem != nullptr)
munmap( protected_mem, ProtectedMemSize ); munmap( protected_mem, ProtectedMemSize );
} }
bool PWStore::insert( const Glib::ustring & key, const char * password ) bool PWStore::insert( const Glib::ustring & key, const char * password )
{ {
if ( protected_mem == NULL ) if (protected_mem == nullptr)
// No locked memory for passwords // No locked memory for passwords
return false; return false;
@ -157,7 +157,7 @@ const char * PWStore::lookup( const Glib::ustring & key )
} }
// No such key // No such key
return NULL; return nullptr;
} }
PWStore::iterator PWStore::find_key( const Glib::ustring & key ) PWStore::iterator PWStore::find_key( const Glib::ustring & key )
@ -174,7 +174,7 @@ PWStore::iterator PWStore::find_key( const Glib::ustring & key )
void PWStore::erase_all() void PWStore::erase_all()
{ {
pw_entries.clear(); pw_entries.clear();
if ( protected_mem != NULL ) if (protected_mem != nullptr)
// WARNING: // WARNING:
// memset() can be optimised away if the compiler knows the memory is not // memset() can be optimised away if the compiler knows the memory is not
// accessed again. In this case this memset() is in a separate method // accessed again. In this case this memset() is in a separate method
@ -206,7 +206,7 @@ static PWStore single_pwstore;
bool PasswordRAMStore::store( const Glib::ustring & key, const char * password ) bool PasswordRAMStore::store( const Glib::ustring & key, const char * password )
{ {
const char * looked_up_pw = single_pwstore.lookup( key ); const char * looked_up_pw = single_pwstore.lookup( key );
if ( looked_up_pw == NULL ) if (looked_up_pw == nullptr)
return single_pwstore.insert( key, password ); return single_pwstore.insert( key, password );
if ( strcmp( looked_up_pw, password ) == 0 ) if ( strcmp( looked_up_pw, password ) == 0 )

View File

@ -156,7 +156,7 @@ bool PipeCapture::OnReadable( Glib::IOCondition condition )
// delimited by an end pointer. // delimited by an end pointer.
new_ptr ++; new_ptr ++;
read_ptr = new_ptr; read_ptr = new_ptr;
if ( read_ptr == NULL ) if (read_ptr == nullptr)
read_ptr = end_ptr; read_ptr = end_ptr;
} }

View File

@ -52,13 +52,13 @@ SupportedFileSystems::SupportedFileSystems()
// their derived FileSystem object, which determines and implements their // their derived FileSystem object, which determines and implements their
// supported actions. // supported actions.
// supported_filesystem() -> true // supported_filesystem() -> true
// 2) Basic supported file systems have a NULL pointer entry, with // 2) Basic supported file systems have a nullptr pointer entry, with
// find_supported_filesystems() creating a basic set of supported actions. // find_supported_filesystems() creating a basic set of supported actions.
// supported_filesystem() -> false // supported_filesystem() -> false
// 3) Unsupported file systems have no entry, and no supported actions. // 3) Unsupported file systems have no entry, and no supported actions.
// supported_filesystem() -> false // supported_filesystem() -> false
m_fs_objects[FS_UNKNOWN] = NULL; m_fs_objects[FS_UNKNOWN] = nullptr;
m_fs_objects[FS_OTHER] = NULL; m_fs_objects[FS_OTHER] = nullptr;
m_fs_objects[FS_BTRFS] = new btrfs(); m_fs_objects[FS_BTRFS] = new btrfs();
m_fs_objects[FS_EXFAT] = new exfat(); m_fs_objects[FS_EXFAT] = new exfat();
m_fs_objects[FS_EXT2] = new ext2(FS_EXT2); m_fs_objects[FS_EXT2] = new ext2(FS_EXT2);
@ -80,16 +80,16 @@ SupportedFileSystems::SupportedFileSystems()
m_fs_objects[FS_REISERFS] = new reiserfs(); m_fs_objects[FS_REISERFS] = new reiserfs();
m_fs_objects[FS_UDF] = new udf(); m_fs_objects[FS_UDF] = new udf();
m_fs_objects[FS_XFS] = new xfs(); m_fs_objects[FS_XFS] = new xfs();
m_fs_objects[FS_APFS] = NULL; m_fs_objects[FS_APFS] = nullptr;
m_fs_objects[FS_ATARAID] = NULL; m_fs_objects[FS_ATARAID] = nullptr;
m_fs_objects[FS_BITLOCKER] = NULL; m_fs_objects[FS_BITLOCKER] = nullptr;
m_fs_objects[FS_GRUB2_CORE_IMG] = NULL; m_fs_objects[FS_GRUB2_CORE_IMG] = nullptr;
m_fs_objects[FS_ISO9660] = NULL; m_fs_objects[FS_ISO9660] = nullptr;
m_fs_objects[FS_LINUX_SWRAID] = NULL; m_fs_objects[FS_LINUX_SWRAID] = nullptr;
m_fs_objects[FS_LINUX_SWSUSPEND] = NULL; m_fs_objects[FS_LINUX_SWSUSPEND] = nullptr;
m_fs_objects[FS_REFS] = NULL; m_fs_objects[FS_REFS] = nullptr;
m_fs_objects[FS_UFS] = NULL; m_fs_objects[FS_UFS] = nullptr;
m_fs_objects[FS_ZFS] = NULL; m_fs_objects[FS_ZFS] = nullptr;
} }
@ -99,7 +99,7 @@ SupportedFileSystems::~SupportedFileSystems()
for (iter = m_fs_objects.begin(); iter != m_fs_objects.end(); iter++) for (iter = m_fs_objects.begin(); iter != m_fs_objects.end(); iter++)
{ {
delete iter->second; delete iter->second;
iter->second = NULL; iter->second = nullptr;
} }
} }
@ -137,7 +137,7 @@ FileSystem* SupportedFileSystems::get_fs_object(FSType fstype) const
{ {
FSObjectsMap::const_iterator iter = m_fs_objects.find(fstype); FSObjectsMap::const_iterator iter = m_fs_objects.find(fstype);
if (iter == m_fs_objects.end()) if (iter == m_fs_objects.end())
return NULL; return nullptr;
else else
return iter->second; return iter->second;
} }
@ -167,7 +167,7 @@ const std::vector<FS>& SupportedFileSystems::get_all_fs_support() const
// Return true for file systems with an implementation class, false otherwise. // Return true for file systems with an implementation class, false otherwise.
bool SupportedFileSystems::supported_filesystem(FSType fstype) const bool SupportedFileSystems::supported_filesystem(FSType fstype) const
{ {
return get_fs_object(fstype) != NULL; return get_fs_object(fstype) != nullptr;
} }

View File

@ -614,7 +614,7 @@ double Utils::sector_to_unit( Sector sectors, Byte_Value sector_size, SIZE_UNIT
int Utils::execute_command( const Glib::ustring & command ) int Utils::execute_command( const Glib::ustring & command )
{ {
Glib::ustring dummy ; Glib::ustring dummy ;
return execute_command( command, NULL, dummy, dummy ); return execute_command(command, nullptr, dummy, dummy);
} }
class CommandStatus class CommandStatus
@ -679,7 +679,7 @@ int Utils::execute_command( const Glib::ustring & command,
Glib::ustring & error, Glib::ustring & error,
bool use_C_locale ) bool use_C_locale )
{ {
return execute_command( command, NULL, output, error, use_C_locale ); return execute_command(command, nullptr, output, error, use_C_locale);
} }
int Utils::execute_command( const Glib::ustring & command, int Utils::execute_command( const Glib::ustring & command,
@ -704,7 +704,7 @@ int Utils::execute_command( const Glib::ustring & command,
Glib::SPAWN_DO_NOT_REAP_CHILD | Glib::SPAWN_SEARCH_PATH, Glib::SPAWN_DO_NOT_REAP_CHILD | Glib::SPAWN_SEARCH_PATH,
use_C_locale ? sigc::ptr_fun( set_locale ) : sigc::slot< void >(), use_C_locale ? sigc::ptr_fun( set_locale ) : sigc::slot< void >(),
&pid, &pid,
( input != NULL ) ? &in : 0, (input != nullptr) ? &in : 0,
&out, &out,
&err ); &err );
} catch (Glib::SpawnError &e) { } catch (Glib::SpawnError &e) {
@ -725,7 +725,7 @@ int Utils::execute_command( const Glib::ustring & command,
outputcapture.connect_signal(); outputcapture.connect_signal();
errorcapture.connect_signal(); errorcapture.connect_signal();
if ( input != NULL && in != -1 ) if (input != nullptr && in != -1)
{ {
// Write small amount of input to pipe to the child process. Linux will // Write small amount of input to pipe to the child process. Linux will
// always accept up 4096 bytes without blocking. See pipe(7). // always accept up 4096 bytes without blocking. See pipe(7).
@ -830,7 +830,7 @@ Glib::ustring Utils::get_lang()
{ {
//Extract base language from string that may look like "en_CA.UTF-8" //Extract base language from string that may look like "en_CA.UTF-8"
// and return in the form "en-CA" // and return in the form "en-CA"
Glib::ustring lang = setlocale( LC_CTYPE, NULL ) ; Glib::ustring lang = setlocale(LC_CTYPE, nullptr);
//Strip off anything after the period "." or at sign "@" //Strip off anything after the period "." or at sign "@"
lang = Utils::regexp_label( lang .c_str(), "^([^.@]*)") ; lang = Utils::regexp_label( lang .c_str(), "^([^.@]*)") ;

View File

@ -71,8 +71,8 @@ namespace GParted
Win_GParted::Win_GParted( const std::vector<Glib::ustring> & user_devices ) Win_GParted::Win_GParted( const std::vector<Glib::ustring> & user_devices )
{ {
copied_partition = NULL; copied_partition = nullptr;
selected_partition_ptr = NULL; selected_partition_ptr = nullptr;
new_count = 1; new_count = 1;
current_device = 0 ; current_device = 0 ;
OPERATIONSLIST_OPEN = true ; OPERATIONSLIST_OPEN = true ;
@ -156,7 +156,7 @@ Win_GParted::Win_GParted( const std::vector<Glib::ustring> & user_devices )
Win_GParted::~Win_GParted() Win_GParted::~Win_GParted()
{ {
delete copied_partition; delete copied_partition;
copied_partition = NULL; copied_partition = nullptr;
} }
void Win_GParted::init_menubar() void Win_GParted::init_menubar()
@ -1070,13 +1070,13 @@ void Win_GParted::Refresh_Visual()
// Refresh copy partition source as necessary and select the largest unallocated // Refresh copy partition source as necessary and select the largest unallocated
// partition if there is one. // partition if there is one.
selected_partition_ptr = NULL; selected_partition_ptr = nullptr;
Sector largest_unalloc_size = -1 ; Sector largest_unalloc_size = -1 ;
Sector current_size ; Sector current_size ;
for (unsigned int i = 0; i < m_display_device.partitions.size(); i++) for (unsigned int i = 0; i < m_display_device.partitions.size(); i++)
{ {
if (copied_partition != NULL && m_display_device.partitions[i].get_path() == copied_partition->get_path()) if (copied_partition != nullptr && m_display_device.partitions[i].get_path() == copied_partition->get_path())
{ {
delete copied_partition; delete copied_partition;
copied_partition = m_display_device.partitions[i].clone(); copied_partition = m_display_device.partitions[i].clone();
@ -1096,7 +1096,7 @@ void Win_GParted::Refresh_Visual()
{ {
for (unsigned int j = 0; j < m_display_device.partitions[i].logicals.size(); j++) for (unsigned int j = 0; j < m_display_device.partitions[i].logicals.size(); j++)
{ {
if (copied_partition != NULL && if (copied_partition != nullptr &&
m_display_device.partitions[i].logicals[j].get_path() == copied_partition->get_path()) m_display_device.partitions[i].logicals[j].get_path() == copied_partition->get_path())
{ {
delete copied_partition; delete copied_partition;
@ -1199,7 +1199,7 @@ void Win_GParted::set_valid_operations()
// Set default name for the open/close crypt menu item. // Set default name for the open/close crypt menu item.
const FileSystem * luks_filesystem_object = gparted_core.get_filesystem_object( FS_LUKS ); const FileSystem * luks_filesystem_object = gparted_core.get_filesystem_object( FS_LUKS );
g_assert( luks_filesystem_object != NULL ); // Bug: LUKS FileSystem object not found g_assert(luks_filesystem_object != nullptr); // Bug: LUKS FileSystem object not found
dynamic_cast<Gtk::Label *>(partitionmenu_items[MENU_TOGGLE_CRYPT_BUSY]->get_child()) dynamic_cast<Gtk::Label *>(partitionmenu_items[MENU_TOGGLE_CRYPT_BUSY]->get_child())
->set_label( luks_filesystem_object->get_custom_text( CTEXT_ACTIVATE_FILESYSTEM ) ); ->set_label( luks_filesystem_object->get_custom_text( CTEXT_ACTIVATE_FILESYSTEM ) );
// Set default name for the file system active/deactivate menu item. // Set default name for the file system active/deactivate menu item.
@ -1345,7 +1345,7 @@ void Win_GParted::set_valid_operations()
// Temporarily disable copying of encrypted content into new partitions // Temporarily disable copying of encrypted content into new partitions
// which can't yet be encrypted, until full LUKS read-write support is // which can't yet be encrypted, until full LUKS read-write support is
// implemented. // implemented.
if ( copied_partition != NULL && if ( copied_partition != nullptr &&
! devices[current_device].readonly && ! devices[current_device].readonly &&
copied_partition->fstype != FS_LUKS ) copied_partition->fstype != FS_LUKS )
{ {
@ -1490,7 +1490,7 @@ void Win_GParted::set_valid_operations()
} }
// See if there is a partition to be copied and it fits inside this selected partition // See if there is a partition to be copied and it fits inside this selected partition
if ( copied_partition != NULL && if ( copied_partition != nullptr &&
( copied_partition->get_filesystem_partition().get_byte_length() <= ( copied_partition->get_filesystem_partition().get_byte_length() <=
selected_filesystem.get_byte_length() ) && selected_filesystem.get_byte_length() ) &&
selected_partition_ptr->status == STAT_REAL && selected_partition_ptr->status == STAT_REAL &&
@ -1828,19 +1828,19 @@ void Win_GParted::show_help(const Glib::ustring & filename /* E.g., "gparted" */
return; return;
} }
GError *error = NULL; GError* error = nullptr;
// Display help window // Display help window
#if HAVE_GTK_SHOW_URI_ON_WINDOW #if HAVE_GTK_SHOW_URI_ON_WINDOW
// NULL is provided for the gtk_show_uri_on_window() parent window // nullptr is provided for the gtk_show_uri_on_window() parent window
// so that failures to launch yelp are reported. // so that failures to launch yelp are reported.
// https://gitlab.gnome.org/GNOME/gparted/-/merge_requests/82#note_1106114 // https://gitlab.gnome.org/GNOME/gparted/-/merge_requests/82#note_1106114
gtk_show_uri_on_window(NULL, uri.c_str(), gtk_get_current_event_time(), &error); gtk_show_uri_on_window(nullptr, uri.c_str(), gtk_get_current_event_time(), &error);
#else #else
GdkScreen *gscreen = gdk_screen_get_default(); GdkScreen *gscreen = gdk_screen_get_default();
gtk_show_uri(gscreen, uri.c_str(), gtk_get_current_event_time(), &error); gtk_show_uri(gscreen, uri.c_str(), gtk_get_current_event_time(), &error);
#endif #endif
if (error != NULL) if (error != nullptr)
{ {
Gtk::MessageDialog errorDialog(*this, Gtk::MessageDialog errorDialog(*this,
_("Failed to open GParted Manual help file"), _("Failed to open GParted Manual help file"),
@ -1998,7 +1998,7 @@ bool Win_GParted::max_amount_prim_reached()
void Win_GParted::activate_resize() void Win_GParted::activate_resize()
{ {
g_assert( selected_partition_ptr != NULL ); // Bug: Partition callback without a selected partition g_assert(selected_partition_ptr != nullptr); // Bug: Partition callback without a selected partition
g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object
const Partition & selected_filesystem_ptn = selected_partition_ptr->get_filesystem_partition(); const Partition & selected_filesystem_ptn = selected_partition_ptr->get_filesystem_partition();
@ -2067,7 +2067,7 @@ void Win_GParted::activate_resize()
dialog .set_transient_for( *this ) ; dialog .set_transient_for( *this ) ;
delete working_ptn; delete working_ptn;
working_ptn = NULL; working_ptn = nullptr;
if (dialog.run() == Gtk::RESPONSE_OK && if (dialog.run() == Gtk::RESPONSE_OK &&
ask_for_password_for_encrypted_resize_as_required(*selected_partition_ptr) ) ask_for_password_for_encrypted_resize_as_required(*selected_partition_ptr) )
@ -2102,7 +2102,7 @@ void Win_GParted::activate_resize()
operation->icon = Utils::mk_pixbuf(*this, Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_MENU); operation->icon = Utils::mk_pixbuf(*this, Gtk::Stock::GOTO_LAST, Gtk::ICON_SIZE_MENU);
delete resized_ptn; delete resized_ptn;
resized_ptn = NULL; resized_ptn = nullptr;
// Display warning if moving a non-extended partition which already exists // Display warning if moving a non-extended partition which already exists
// on the disk. // on the disk.
@ -2153,7 +2153,7 @@ bool Win_GParted::ask_for_password_for_encrypted_resize_as_required(const Partit
return true; return true;
const char *pw = PasswordRAMStore::lookup(partition.uuid); const char *pw = PasswordRAMStore::lookup(partition.uuid);
if (pw != NULL) if (pw != nullptr)
// GParted already has a password for this encryption mapping which was // GParted already has a password for this encryption mapping which was
// previously used successfully or tested for correctness. // previously used successfully or tested for correctness.
// //
@ -2214,7 +2214,7 @@ bool Win_GParted::ask_for_password_for_encrypted_resize_as_required(const Partit
void Win_GParted::activate_copy() void Win_GParted::activate_copy()
{ {
g_assert( selected_partition_ptr != NULL ); // Bug: Partition callback without a selected partition g_assert(selected_partition_ptr != nullptr); // Bug: Partition callback without a selected partition
g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object
delete copied_partition; delete copied_partition;
@ -2223,8 +2223,8 @@ void Win_GParted::activate_copy()
void Win_GParted::activate_paste() void Win_GParted::activate_paste()
{ {
g_assert( copied_partition != NULL ); // Bug: Paste called without partition to copy g_assert(copied_partition != nullptr); // Bug: Paste called without partition to copy
g_assert( selected_partition_ptr != NULL ); // Bug: Partition callback without a selected partition g_assert(selected_partition_ptr != nullptr); // Bug: Partition callback without a selected partition
g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object
// Unrecognised whole disk device (See GParted_Core::set_device_from_disk(), "unrecognized") // Unrecognised whole disk device (See GParted_Core::set_device_from_disk(), "unrecognized")
@ -2258,7 +2258,7 @@ void Win_GParted::activate_paste()
*selected_partition_ptr, *selected_partition_ptr,
*part_temp); *part_temp);
delete part_temp; delete part_temp;
part_temp = NULL; part_temp = nullptr;
dialog .set_transient_for( *this ); dialog .set_transient_for( *this );
if ( dialog .run() == Gtk::RESPONSE_OK ) if ( dialog .run() == Gtk::RESPONSE_OK )
@ -2368,7 +2368,7 @@ void Win_GParted::activate_paste()
operation->icon = Utils::mk_pixbuf(*this, Gtk::Stock::COPY, Gtk::ICON_SIZE_MENU); operation->icon = Utils::mk_pixbuf(*this, Gtk::Stock::COPY, Gtk::ICON_SIZE_MENU);
delete partition_new; delete partition_new;
partition_new = NULL; partition_new = nullptr;
Add_Operation( devices[current_device], operation ); Add_Operation( devices[current_device], operation );
@ -2396,7 +2396,7 @@ void Win_GParted::activate_paste()
void Win_GParted::activate_new() void Win_GParted::activate_new()
{ {
g_assert( selected_partition_ptr != NULL ); // Bug: Partition callback without a selected partition g_assert(selected_partition_ptr != nullptr); // Bug: Partition callback without a selected partition
g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object
// Unrecognised whole disk device (See GParted_Core::set_device_from_disk(), "unrecognized") // Unrecognised whole disk device (See GParted_Core::set_device_from_disk(), "unrecognized")
@ -2437,7 +2437,7 @@ void Win_GParted::activate_new()
void Win_GParted::activate_delete() void Win_GParted::activate_delete()
{ {
g_assert( selected_partition_ptr != NULL ); // Bug: Partition callback without a selected partition g_assert(selected_partition_ptr != nullptr); // Bug: Partition callback without a selected partition
g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object
// VGNAME from mount mount // VGNAME from mount mount
@ -2474,7 +2474,7 @@ void Win_GParted::activate_delete()
} }
//if partition is on the clipboard...(NOTE: we can't use Partition::== here..) //if partition is on the clipboard...(NOTE: we can't use Partition::== here..)
if ( copied_partition != NULL && selected_partition_ptr->get_path() == copied_partition->get_path() ) if (copied_partition != nullptr && selected_partition_ptr->get_path() == copied_partition->get_path())
{ {
Gtk::MessageDialog dialog( *this, Gtk::MessageDialog dialog( *this,
Glib::ustring::compose( _("Are you sure you want to delete %1?"), Glib::ustring::compose( _("Are you sure you want to delete %1?"),
@ -2501,7 +2501,7 @@ void Win_GParted::activate_delete()
// Deleting partition on the clipboard. Clear clipboard. // Deleting partition on the clipboard. Clear clipboard.
delete copied_partition; delete copied_partition;
copied_partition = NULL; copied_partition = nullptr;
} }
// If deleted one is NEW, it doesn't make sense to add it to the operationslist, // If deleted one is NEW, it doesn't make sense to add it to the operationslist,
@ -2550,7 +2550,7 @@ void Win_GParted::activate_delete()
void Win_GParted::activate_info() void Win_GParted::activate_info()
{ {
g_assert( selected_partition_ptr != NULL ); // Bug: Partition callback without a selected partition g_assert(selected_partition_ptr != nullptr); // Bug: Partition callback without a selected partition
g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object
Dialog_Partition_Info dialog( *selected_partition_ptr ); Dialog_Partition_Info dialog( *selected_partition_ptr );
@ -2560,7 +2560,7 @@ void Win_GParted::activate_info()
void Win_GParted::activate_format( FSType new_fs ) void Win_GParted::activate_format( FSType new_fs )
{ {
g_assert( selected_partition_ptr != NULL ); // Bug: Partition callback without a selected partition g_assert(selected_partition_ptr != nullptr); // Bug: Partition callback without a selected partition
g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object
const Partition & filesystem_ptn = selected_partition_ptr->get_filesystem_partition(); const Partition & filesystem_ptn = selected_partition_ptr->get_filesystem_partition();
@ -2700,18 +2700,19 @@ void Win_GParted::activate_format( FSType new_fs )
} }
delete temp_ptn; delete temp_ptn;
temp_ptn = NULL; temp_ptn = nullptr;
} }
bool Win_GParted::open_encrypted_partition( const Partition & partition, bool Win_GParted::open_encrypted_partition( const Partition & partition,
const char * entered_password, const char * entered_password,
Glib::ustring & message ) Glib::ustring & message )
{ {
const char * pw = NULL; const char* pw = nullptr;
if ( entered_password == NULL ) if (entered_password == nullptr)
{ {
pw = PasswordRAMStore::lookup( partition.uuid ); pw = PasswordRAMStore::lookup( partition.uuid );
if ( pw == NULL ) if (pw == nullptr)
{ {
// Internal documentation message never shown to user. // Internal documentation message never shown to user.
message = "No stored password available"; message = "No stored password available";
@ -2739,7 +2740,7 @@ bool Win_GParted::open_encrypted_partition( const Partition & partition,
Glib::ustring error; Glib::ustring error;
bool success = ! Utils::execute_command( cmd, pw, output, error ); bool success = ! Utils::execute_command( cmd, pw, output, error );
hide_pulsebar(); hide_pulsebar();
if ( success && pw != NULL ) if (success && pw != nullptr)
// Save the password just entered and successfully used to open the LUKS // Save the password just entered and successfully used to open the LUKS
// mapping. // mapping.
PasswordRAMStore::store( partition.uuid, pw ); PasswordRAMStore::store( partition.uuid, pw );
@ -2754,7 +2755,7 @@ bool Win_GParted::open_encrypted_partition( const Partition & partition,
void Win_GParted::toggle_crypt_busy_state() void Win_GParted::toggle_crypt_busy_state()
{ {
g_assert( selected_partition_ptr != NULL ); // Bug: Partition callback without a selected partition g_assert(selected_partition_ptr != nullptr); // Bug: Partition callback without a selected partition
g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object
enum Action enum Action
@ -2808,7 +2809,7 @@ void Win_GParted::toggle_crypt_busy_state()
case LUKSOPEN: case LUKSOPEN:
{ {
// Attempt to unlock LUKS using stored passphrase first. // Attempt to unlock LUKS using stored passphrase first.
success = open_encrypted_partition( *selected_partition_ptr, NULL, error_msg ); success = open_encrypted_partition(*selected_partition_ptr, nullptr, error_msg);
if ( success ) if ( success )
break; break;
@ -2941,7 +2942,7 @@ void Win_GParted::show_toggle_failure_dialog( const Glib::ustring & failure_summ
void Win_GParted::toggle_fs_busy_state() void Win_GParted::toggle_fs_busy_state()
{ {
g_assert( selected_partition_ptr != NULL ); // Bug: Partition callback without a selected partition g_assert(selected_partition_ptr != nullptr); // Bug: Partition callback without a selected partition
g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object
enum Action enum Action
@ -3054,7 +3055,7 @@ void Win_GParted::toggle_fs_busy_state()
void Win_GParted::activate_mount_partition( unsigned int index ) void Win_GParted::activate_mount_partition( unsigned int index )
{ {
g_assert( selected_partition_ptr != NULL ); // Bug: Partition callback without a selected partition g_assert(selected_partition_ptr != nullptr); // Bug: Partition callback without a selected partition
g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object
Glib::ustring disallowed_msg = _("The mount action cannot be performed when an operation is pending for the partition."); Glib::ustring disallowed_msg = _("The mount action cannot be performed when an operation is pending for the partition.");
@ -3261,7 +3262,7 @@ void Win_GParted::activate_attempt_rescue_data()
void Win_GParted::activate_manage_flags() void Win_GParted::activate_manage_flags()
{ {
g_assert( selected_partition_ptr != NULL ); // Bug: Partition callback without a selected partition g_assert(selected_partition_ptr != nullptr); // Bug: Partition callback without a selected partition
g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object
get_window()->set_cursor(Gdk::Cursor::create(Gdk::WATCH)); get_window()->set_cursor(Gdk::Cursor::create(Gdk::WATCH));
@ -3287,7 +3288,7 @@ void Win_GParted::activate_manage_flags()
void Win_GParted::activate_check() void Win_GParted::activate_check()
{ {
g_assert( selected_partition_ptr != NULL ); // Bug: Partition callback without a selected partition g_assert(selected_partition_ptr != nullptr); // Bug: Partition callback without a selected partition
g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object
if (! ask_for_password_for_encrypted_resize_as_required(*selected_partition_ptr)) if (! ask_for_password_for_encrypted_resize_as_required(*selected_partition_ptr))
@ -3311,7 +3312,7 @@ void Win_GParted::activate_check()
void Win_GParted::activate_label_filesystem() void Win_GParted::activate_label_filesystem()
{ {
g_assert( selected_partition_ptr != NULL ); // Bug: Partition callback without a selected partition g_assert(selected_partition_ptr != nullptr); // Bug: Partition callback without a selected partition
g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object
const Partition & filesystem_ptn = selected_partition_ptr->get_filesystem_partition(); const Partition & filesystem_ptn = selected_partition_ptr->get_filesystem_partition();
@ -3332,7 +3333,7 @@ void Win_GParted::activate_label_filesystem()
operation->icon = Utils::mk_pixbuf(*this, Gtk::Stock::EXECUTE, Gtk::ICON_SIZE_MENU); operation->icon = Utils::mk_pixbuf(*this, Gtk::Stock::EXECUTE, Gtk::ICON_SIZE_MENU);
delete part_temp; delete part_temp;
part_temp = NULL; part_temp = nullptr;
Add_Operation( devices[current_device], operation ); Add_Operation( devices[current_device], operation );
// Try to merge this label file system operation with all previous // Try to merge this label file system operation with all previous
@ -3345,7 +3346,7 @@ void Win_GParted::activate_label_filesystem()
void Win_GParted::activate_name_partition() void Win_GParted::activate_name_partition()
{ {
g_assert( selected_partition_ptr != NULL ); // Bug: Partition callback without a selected partition g_assert(selected_partition_ptr != nullptr); // Bug: Partition callback without a selected partition
g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object
Dialog_Partition_Name dialog( *selected_partition_ptr, Dialog_Partition_Name dialog( *selected_partition_ptr,
@ -3366,7 +3367,7 @@ void Win_GParted::activate_name_partition()
operation->icon = Utils::mk_pixbuf(*this, Gtk::Stock::EXECUTE, Gtk::ICON_SIZE_MENU); operation->icon = Utils::mk_pixbuf(*this, Gtk::Stock::EXECUTE, Gtk::ICON_SIZE_MENU);
delete part_temp; delete part_temp;
part_temp = NULL; part_temp = nullptr;
Add_Operation( devices[current_device], operation ); Add_Operation( devices[current_device], operation );
// Try to merge this name partition operation with all previous // Try to merge this name partition operation with all previous
@ -3379,7 +3380,7 @@ void Win_GParted::activate_name_partition()
void Win_GParted::activate_change_uuid() void Win_GParted::activate_change_uuid()
{ {
g_assert( selected_partition_ptr != NULL ); // Bug: Partition callback without a selected partition g_assert(selected_partition_ptr != nullptr); // Bug: Partition callback without a selected partition
g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid display partition object
const Partition & filesystem_ptn = selected_partition_ptr->get_filesystem_partition(); const Partition & filesystem_ptn = selected_partition_ptr->get_filesystem_partition();
@ -3424,7 +3425,7 @@ void Win_GParted::activate_change_uuid()
operation->icon = Utils::mk_pixbuf(*this, Gtk::Stock::EXECUTE, Gtk::ICON_SIZE_MENU); operation->icon = Utils::mk_pixbuf(*this, Gtk::Stock::EXECUTE, Gtk::ICON_SIZE_MENU);
delete temp_ptn; delete temp_ptn;
temp_ptn = NULL; temp_ptn = nullptr;
Add_Operation( devices[current_device], operation ); Add_Operation( devices[current_device], operation );
// Try to merge this change UUID operation with all previous operations. // Try to merge this change UUID operation with all previous operations.

View File

@ -159,7 +159,7 @@ bool luks::resize( const Partition & partition_new, OperationDetail & operationd
// device sector size. // device sector size.
size = "--size " + Utils::num_to_str( ( partition_new.get_byte_length() - mapping.offset ) / 512LL ) + " "; size = "--size " + Utils::num_to_str( ( partition_new.get_byte_length() - mapping.offset ) / 512LL ) + " ";
const char *pw = NULL; const char* pw = nullptr;
if (mapping.key_loc == KEYLOC_KeyRing) if (mapping.key_loc == KEYLOC_KeyRing)
pw = PasswordRAMStore::lookup(partition_new.uuid); pw = PasswordRAMStore::lookup(partition_new.uuid);