After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 539092 - Remove unnecessary null pointer checks
Remove unnecessary null pointer checks
Status: RESOLVED FIXED
Product: gparted
Classification: Other
Component: application
0.3.7
Other All
: Normal trivial
: ---
Assigned To: gparted maintainers alias
gparted maintainers alias
Depends on:
Blocks:
 
 
Reported: 2008-06-19 07:17 UTC by Markus Elfring
Modified: 2010-10-29 16:29 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
little clean-up for destructors (1.11 KB, patch)
2008-06-19 07:21 UTC, Markus Elfring
none Details | Review
tiny clean-up for a member function (369 bytes, patch)
2008-06-19 07:49 UTC, Markus Elfring
none Details | Review
little clean-up for destructors (1.14 KB, patch)
2008-06-19 08:15 UTC, Markus Elfring
none Details | Review
update suggestion (2.06 KB, patch)
2010-06-24 15:50 UTC, Markus Elfring
none Details | Review

Description Markus Elfring 2008-06-19 07:17:35 UTC
The null pointer checks for the pointers "p_filesystem", "frame_resizer_base", "cursor_resize" and "cursor_move" are not needed in the corresponding destructors.
http://dietmar-kuehl.de/mirror/c++-faq/freestore-mgmt.html#faq-16.8

I suggest to adjust their implementations.
http://svn.gnome.org/viewvc/gparted/trunk/src/GParted_Core.cc?revision=857&view=markup
http://svn.gnome.org/viewvc/gparted/trunk/src/Frame_Resizer_Base.cc?revision=696&view=markup
http://svn.gnome.org/viewvc/gparted/trunk/src/Dialog_Base_Partition.cc?revision=856&view=markup
Comment 1 Markus Elfring 2008-06-19 07:21:44 UTC
Created attachment 113025 [details] [review]
little clean-up for destructors
Comment 2 Markus Elfring 2008-06-19 07:49:49 UTC
Created attachment 113028 [details] [review]
tiny clean-up for a member function
Comment 3 Markus Elfring 2008-06-19 08:15:08 UTC
Created attachment 113030 [details] [review]
little clean-up for destructors
Comment 4 Markus Elfring 2010-06-24 15:50:30 UTC
Created attachment 164518 [details] [review]
update suggestion

Would you like to integrate the appended changes into your source code repository?
Comment 5 Curtis Gedak 2010-10-06 18:38:33 UTC
Thank you Markus for your persistence with this bug report, and for updating the patch for the git repository.

I have done lots of programming in the C language and hence am aware of the problems that occur when dereferencing NULL pointers.  The link you provided was very useful to confirm that this is not a problem when deleting pointers in C++.

It is useful to de-clutter source code whenever one can.  It helps with the code readability.  Not many people would have noticed this so thank you for pointing it out.  :-)

I have committed your patch to the gnome git repository for inclusion in the next release of GParted (0.7.0).

The relevant commit can be viewed at the following link:
http://git.gnome.org/browse/gparted/commit/?id=1e2562adda8d315c36a709ce9b8086f3e2e97933

Please feel free to close this bug report, or if you find more situations then a patch would be great.

Sincerely,
Curtis Gedak

PS:  I will continue to review and comment on the other bug reports you have posted.  I am juggling many competing priorities, so your patience is appreciated.
Comment 6 Curtis Gedak 2010-10-29 16:29:28 UTC
Thanks go to Markus for providing a patch to simplify the GParted source code.

The enhancements to address this bug report have been included in GParted 0.7.0
which was released on October 29, 2010.

Closing this bug report.