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 794732 - Fix various compiler warnings
Fix various compiler warnings
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2018-03-27 15:57 UTC by Emmanuele Bassi (:ebassi)
Modified: 2018-03-28 10:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Do not use g_autofree (1.94 KB, patch)
2018-03-27 15:57 UTC, Emmanuele Bassi (:ebassi)
committed Details | Review
Ignore GCC memory overflow warnings when testing overflows (943 bytes, patch)
2018-03-27 15:58 UTC, Emmanuele Bassi (:ebassi)
committed Details | Review
Initialize variables before using them (1.43 KB, patch)
2018-03-27 15:58 UTC, Emmanuele Bassi (:ebassi)
committed Details | Review
Initialize boolean variable (890 bytes, patch)
2018-03-27 15:58 UTC, Emmanuele Bassi (:ebassi)
none Details | Review
Initialize variable (1.61 KB, patch)
2018-03-27 15:58 UTC, Emmanuele Bassi (:ebassi)
committed Details | Review
Initialize boolean variable (946 bytes, patch)
2018-03-27 17:24 UTC, Emmanuele Bassi (:ebassi)
committed Details | Review

Description Emmanuele Bassi (:ebassi) 2018-03-27 15:57:43 UTC
SSIA.

The first attachment is kind of unrelated, but it solves an issue reported here:

https://gitlab.gnome.org/GNOME/gtk/issues/136

The other attachments are related to building GLib as a sub-project when building GTK on our continuous integration pipeline, and make it impossible to build GLib with `--werror` enabled.
Comment 1 Emmanuele Bassi (:ebassi) 2018-03-27 15:57:55 UTC
Created attachment 370203 [details] [review]
Do not use g_autofree

The g_auto macros are available only with GCC-compatible compilers on
Unix, but having __attribute__((cleanup)) is not part of our toolchain
requirements, so we shouldn't use it — even if we are building on
Unix-compatible systems.
Comment 2 Emmanuele Bassi (:ebassi) 2018-03-27 15:58:01 UTC
Created attachment 370204 [details] [review]
Ignore GCC memory overflow warnings when testing overflows

We know we are overflowing the maximum allocation: it's what we're
testing for.
Comment 3 Emmanuele Bassi (:ebassi) 2018-03-27 15:58:07 UTC
Created attachment 370205 [details] [review]
Initialize variables before using them

Avoid a compiler warning when using the average, minimum, and maximum
elapsed variables without initializing them.
Comment 4 Emmanuele Bassi (:ebassi) 2018-03-27 15:58:12 UTC
Created attachment 370206 [details] [review]
Initialize boolean variable

There can be branches where the `interesting` variable isn't
initialized.
Comment 5 Emmanuele Bassi (:ebassi) 2018-03-27 15:58:17 UTC
Created attachment 370207 [details] [review]
Initialize variable

The `mount_monitor` variable is only set if the boolean
`with_mount_monitor` variable is set to TRUE, but the compiler does not
know that, so it'll warn when calling `g_clear_object()` even if the
clearing operation is gated with the same boolean.

Initializing with NULL does not cost us anything, and eliminates a
conditional branch.
Comment 6 Philip Withnall 2018-03-27 16:16:31 UTC
Review of attachment 370203 [details] [review]:

++
Comment 7 Philip Withnall 2018-03-27 16:17:08 UTC
Review of attachment 370204 [details] [review]:

++
Comment 8 Philip Withnall 2018-03-27 16:17:33 UTC
Review of attachment 370205 [details] [review]:

++
Comment 9 Philip Withnall 2018-03-27 16:19:48 UTC
Review of attachment 370206 [details] [review]:

I’d slightly prefer to add an `else` branch on the main `if`, which is where the missing initialisation is, and explicitly initialise it there. Then if someone adds a new branch without initialising it there, they will get the warning again, rather than a default value which might not be correct for the branch they’ve added.
Comment 10 Philip Withnall 2018-03-27 16:20:37 UTC
Review of attachment 370207 [details] [review]:

++
Comment 11 Emmanuele Bassi (:ebassi) 2018-03-27 17:24:47 UTC
Created attachment 370215 [details] [review]
Initialize boolean variable

There can be branches where the `interesting` variable isn't
initialized.
Comment 12 Philip Withnall 2018-03-27 22:36:19 UTC
Review of attachment 370215 [details] [review]:

++
Comment 13 Emmanuele Bassi (:ebassi) 2018-03-28 10:53:06 UTC
Attachment 370203 [details] pushed as 07731ff - Do not use g_autofree
Attachment 370204 [details] pushed as 327c379 - Ignore GCC memory overflow warnings when testing overflows
Attachment 370205 [details] pushed as 94d4e8b - Initialize variables before using them
Attachment 370207 [details] pushed as ac42183 - Initialize variable
Attachment 370215 [details] pushed as dd8d33d - Initialize boolean variable