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 743164 - Always normalize boolean setters
Always normalize boolean setters
Status: RESOLVED FIXED
Product: gnome-builder
Classification: Other
Component: general
unspecified
Other Linux
: Low trivial
: ---
Assigned To: GNOME Builder Maintainers
GNOME Builder Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-01-19 09:21 UTC by Paolo Borelli
Modified: 2015-01-20 04:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
convention: use !! to normalize boolean params and guint 1 bit flag (10.00 KB, patch)
2015-01-20 04:56 UTC, Christian Hergert
committed Details | Review

Description Paolo Borelli 2015-01-19 09:21:46 UTC
While browsing the code I noticed that at least some of the boolean setters are not normalizing the input value.

It is a good practice to always do

foo_set_bar(gboolean x)
{
  x = !!x;

  ...
}

in case the caller passes in an integer value different from TRUE/FALSE
Comment 1 Christian Hergert 2015-01-19 09:30:01 UTC
It would be nice to have, but I get the feeling that since we don't use "x = 1" type statements in our code base, that this type of bug wouldn't be very common.

I also hope that G-I sends the right thing (when we finally get to opening that up).
Comment 2 Christian Hergert 2015-01-19 09:31:01 UTC
i guess in general, we'd be more likely to hit it when assigning from pointers accidentally. at least those will warn with --enable-maintainer-flags though.
Comment 3 Christian Hergert 2015-01-20 04:56:02 UTC
Created attachment 294942 [details] [review]
convention: use !! to normalize boolean params and guint 1 bit flag
Comment 4 Christian Hergert 2015-01-20 04:56:18 UTC
Attachment 294942 [details] pushed as 9873d28 - convention: use !! to normalize boolean params and guint 1 bit flag