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 753999 - De-duplicate GridElement creation
De-duplicate GridElement creation
Status: RESOLVED FIXED
Product: gnome-disk-utility
Classification: Core
Component: Disks UI
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: gnome-disk-utility-maint
gnome-disk-utility-maint
Depends on:
Blocks:
 
 
Reported: 2015-08-23 22:44 UTC by Nicholas Bishop
Modified: 2015-08-25 23:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
De-duplicate GridElement creation (5.72 KB, patch)
2015-08-23 22:44 UTC, Nicholas Bishop
none Details | Review
Updated patch to remove comment and const keyword (5.57 KB, patch)
2015-08-24 01:02 UTC, Nicholas Bishop
committed Details | Review

Description Nicholas Bishop 2015-08-23 22:44:32 UTC
Created attachment 309898 [details] [review]
De-duplicate GridElement creation

Minor code cleanup.
Comment 1 Michael Catanzaro 2015-08-24 00:18:50 UTC
Review of attachment 309898 [details] [review]:

Thanks for cleaning this up and for working to implement Allan's design!

::: src/disks/gduvolumegrid.c
@@ +71,3 @@
+ * - GridElement.size_ratio is set to 1
+ * - All other fields are zeroed
+ */

The comment is accurate, but also useless: everything you say there is clear from just glancing at the code. You can simply remove it.

@@ +73,3 @@
+ */
+static GridElement *
+grid_element_new (const GduVolumeGridElementType type)

Ah, you must be coming from C++. :) There using const in parameter lists is very useful for pass-by-reference parameters. There's no value in using it on pass-by-value parameters, though: consider that whether a pass-by-value parameter is modified is just an implementation detail of the function, and there's no reason for that to be exposed in the function signature.

There is only one place we generally use const: for character strings, to indicate whether ownership is transferred. You have to free a "char *" parameter, but not a "const char *".
Comment 2 Nicholas Bishop 2015-08-24 01:02:02 UTC
Created attachment 309900 [details] [review]
Updated patch to remove comment and const keyword
Comment 3 Michael Catanzaro 2015-08-24 01:21:11 UTC
Comment on attachment 309900 [details] [review]
Updated patch to remove comment and const keyword

Looks good, thanks!
Comment 4 Michael Catanzaro 2015-08-25 22:59:13 UTC
I'm unexpectedly touching this code now so let's push this now