GNOME Bugzilla – Bug 793195
Fix compiler warnings
Last modified: 2018-02-12 17:06:35 UTC
Some cause more problems with Clang and are trickier to deal with, but this should make the library buildable with -Werror. The following warnings have been fixed: * shadowed variables: renamed or recycled where it makes sense; * incompatible type conversions: * types equalized in comparisons, * initializing a c-string array with literals: array turned const, but constness cast-out when passing to g_spawn_sync(), since the array is guaranteed to not be modified, * XGetWindowProperty() calls: a void pointer used to hold returned property data to retain required alignment when casting later; * switching on enumerations: missing cases added; * redundant const-qualifiers in pointers: those assumedly should have been const pointers, so that’s what they became; * GTK+/GDK deprecation warnings: preprocessor definition to disable those is now passed unconditionally, which goes against --enable-deprecation-flags and is the reason why it was removed.
Created attachment 367927 [details] [review] Fix compiler warnings
I tried to be as descriptive as possible, but feedback/questions welcome. This is mostly to make Continuous happy again.
Any news on this? Not having to pass --disable-Werror would be nice.
(In reply to Ernestas Kulik from comment #0) > * GTK+/GDK deprecation warnings: preprocessor definition to disable > those is now passed unconditionally, which goes against > --enable-deprecation-flags and is the reason why it was removed. I guess it's a lot of work to fix these?
(In reply to Michael Catanzaro from comment #4) > (In reply to Ernestas Kulik from comment #0) > > * GTK+/GDK deprecation warnings: preprocessor definition to disable > > those is now passed unconditionally, which goes against > > --enable-deprecation-flags and is the reason why it was removed. > > I guess it's a lot of work to fix these? There are some non-trivial changes that need to be made, so I decided it would be better to just not emit the warnings for now.
Created attachment 368266 [details] [review] Fix redundant const qualifiers The pointers in DefaultInputSource don’t correctly express that they are const and not just point to const data.
Created attachment 368267 [details] [review] Fix comparisons with differing signedness
Created attachment 368268 [details] [review] Don’t shadow variables Especially if the types don’t match.
Created attachment 368269 [details] [review] Handle all cases when switching on an enum
Created attachment 368270 [details] [review] Disable deprecation warnings explicitly This additionally removes the ability to pass deprecation flags to configure.ac. Revert when GTK/GDK warnings are fixed, or just don’t define the magic macros.
Created attachment 368271 [details] [review] Silence warnings for increased pointer alignment Not much to do other than some clever casting, since Xlib insists on receiving char pointers.
Created attachment 368272 [details] [review] Add const-qualifier when assigning string literals This also requires some casting when using due to legacy requirements. The string is never modified, so it’s fine.
Attachment 368266 [details] pushed as 152bc57 - Fix redundant const qualifiers Attachment 368267 [details] pushed as 5cca208 - Fix comparisons with differing signedness Attachment 368268 [details] pushed as 5d5fa67 - Don’t shadow variables Attachment 368269 [details] pushed as d52b1a2 - Handle all cases when switching on an enum Attachment 368270 [details] pushed as f687629 - Disable deprecation warnings explicitly Attachment 368271 [details] pushed as 5db5f5d - Silence warnings for increased pointer alignment Attachment 368272 [details] pushed as 50299b7 - Add const-qualifier when assigning string literals