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 611692 - Add more warning flags
Add more warning flags
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal enhancement
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on: 611690 624001
Blocks:
 
 
Reported: 2010-03-03 11:47 UTC by Benjamin Otte (Company)
Modified: 2011-02-28 15:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
remove unused gst_element_default_error() (1.92 KB, patch)
2010-03-03 11:49 UTC, Benjamin Otte (Company)
committed Details | Review
registry: remove unused function (1.10 KB, patch)
2010-03-03 11:49 UTC, Benjamin Otte (Company)
rejected Details | Review
fixme: Add -Wno-error to avoid Bison warnings (898 bytes, patch)
2010-03-03 11:49 UTC, Benjamin Otte (Company)
needs-work Details | Review
Fix signedness warnings (36.12 KB, patch)
2010-03-03 11:49 UTC, Benjamin Otte (Company)
reviewed Details | Review
Remove gst_element_request_compatible_pad() (2.26 KB, patch)
2010-03-03 11:49 UTC, Benjamin Otte (Company)
rejected Details | Review
bytewriter: Fix float/double write functions to match bytereader (3.38 KB, patch)
2010-03-03 11:49 UTC, Benjamin Otte (Company)
none Details | Review
Fixes for -Wmissing-declarations -Wmissing-prototypes (24.70 KB, patch)
2010-03-03 11:50 UTC, Benjamin Otte (Company)
committed Details | Review
Make code safe for -Wredundant-decls (14.17 KB, patch)
2010-03-03 11:50 UTC, Benjamin Otte (Company)
committed Details | Review
Fixes for -Wold-style-definition (1.71 KB, patch)
2010-03-03 11:50 UTC, Benjamin Otte (Company)
committed Details | Review
benchmarks: Remove unneeded g_thread_exit() (662 bytes, patch)
2010-03-03 11:50 UTC, Benjamin Otte (Company)
committed Details | Review
Include gstversion.h for GST_VERSION_NANO (717 bytes, patch)
2010-03-03 11:50 UTC, Benjamin Otte (Company)
committed Details | Review
Fixes for -Wswitch-default (12.72 KB, patch)
2010-03-03 11:50 UTC, Benjamin Otte (Company)
reviewed Details | Review
Fixes for -Wwrite-strings (40.87 KB, patch)
2010-03-03 11:50 UTC, Benjamin Otte (Company)
committed Details | Review
Add all the warning flags we just cleaned up for. (1.43 KB, patch)
2010-03-03 11:50 UTC, Benjamin Otte (Company)
none Details | Review

Description Benjamin Otte (Company) 2010-03-03 11:47:46 UTC
The following patches provide cleanup of the core module. The last patch adds the used gcc warning flags to configure.
Comment 1 Benjamin Otte (Company) 2010-03-03 11:49:40 UTC
Created attachment 155113 [details] [review]
remove unused gst_element_default_error()
Comment 2 Benjamin Otte (Company) 2010-03-03 11:49:44 UTC
Created attachment 155114 [details] [review]
registry: remove unused function

Actually, there was two functions with the same name, but only one was
used.
Comment 3 Benjamin Otte (Company) 2010-03-03 11:49:47 UTC
Created attachment 155115 [details] [review]
fixme: Add -Wno-error to avoid Bison warnings

This needs to be handled properly, but I have no clue how yet
Comment 4 Benjamin Otte (Company) 2010-03-03 11:49:50 UTC
Created attachment 155116 [details] [review]
Fix signedness warnings

... and all the other things to make the code not throw warnings with
-Wextra -Wno-missing-field-initializers -Wno-unused-parameter
Comment 5 Benjamin Otte (Company) 2010-03-03 11:49:54 UTC
Created attachment 155117 [details] [review]
Remove gst_element_request_compatible_pad()

No header declares it.
Comment 6 Benjamin Otte (Company) 2010-03-03 11:49:57 UTC
Created attachment 155118 [details] [review]
bytewriter: Fix float/double write functions to match bytereader
Comment 7 Benjamin Otte (Company) 2010-03-03 11:50:00 UTC
Created attachment 155119 [details] [review]
Fixes for -Wmissing-declarations -Wmissing-prototypes

Does not include fix for bison/flex generated code.
Comment 8 Benjamin Otte (Company) 2010-03-03 11:50:03 UTC
Created attachment 155120 [details] [review]
Make code safe for -Wredundant-decls

Includes a tiny change of the GST_BOILERPLATE_FULL() macro:
The get_type() function is no longer declared before being defined.
Comment 9 Benjamin Otte (Company) 2010-03-03 11:50:07 UTC
Created attachment 155121 [details] [review]
Fixes for -Wold-style-definition
Comment 10 Benjamin Otte (Company) 2010-03-03 11:50:11 UTC
Created attachment 155122 [details] [review]
benchmarks: Remove unneeded g_thread_exit()
Comment 11 Benjamin Otte (Company) 2010-03-03 11:50:14 UTC
Created attachment 155123 [details] [review]
Include gstversion.h for GST_VERSION_NANO

Fixes -Wundef
Comment 12 Benjamin Otte (Company) 2010-03-03 11:50:18 UTC
Created attachment 155124 [details] [review]
Fixes for -Wswitch-default
Comment 13 Benjamin Otte (Company) 2010-03-03 11:50:22 UTC
Created attachment 155126 [details] [review]
Fixes for -Wwrite-strings

This changes some APIs in compatible ways:
- Some functions now take "const char *" arguments, not "char *"
- Some structs now have "conts char *" members, not "char *"
The changes may cause warnings when compiling with the right warning
flags. You've been warned.
Comment 14 Benjamin Otte (Company) 2010-03-03 11:50:25 UTC
Created attachment 155127 [details] [review]
Add all the warning flags we just cleaned up for.
Comment 15 Benjamin Otte (Company) 2010-03-03 11:55:17 UTC
Some comments:

- Patches are against 0.10.26.3
- The testsuite is not fixed yet - make runs without warnings though.
Comment 16 Benjamin Otte (Company) 2010-03-03 12:02:27 UTC
Oh, very important:

I don't have a proper fix for the crappy bison-generated code yet. My idea was to introduce NOERROR_CFLAGS and allow using them for imported or generated code, but I don't have an idea how to do this with forte.
It would look like this:
crappy_files_la_CFLAGS = $(GST_ALL_CFLAGS) $(NOERROR_CFLAGS)

NOERROR_CFLAGS would be set to "-Wno-error".

Note that this would still show the warnings, just not abort compilation.
Comment 17 Tim-Philipp Müller 2010-03-03 12:20:54 UTC
Review of attachment 155115 [details] [review]:

I don't think we can assume all compilers support -Wno-error
Comment 18 Benjamin Otte (Company) 2010-03-03 12:31:30 UTC
(In reply to comment #17)
> Review of attachment 155115 [details] [review]:
> 
> I don't think we can assume all compilers support -Wno-error
>
Yeah, that's why there's comment 16 and the commit you quoted says "fixme". :)
Comment 19 Tim-Philipp Müller 2010-03-04 12:21:53 UTC
Comment on attachment 155124 [details] [review]
Fixes for -Wswitch-default

Not a big fan of this. I don't think this is useful in a GStreamer context. In the one or two places where it might be useful (e.g. gstvideo) it should just be added specifically. So -1 from me. This is just a nuisance.
Comment 20 Tim-Philipp Müller 2010-03-04 12:37:24 UTC
Comment on attachment 155119 [details] [review]
Fixes for -Wmissing-declarations -Wmissing-prototypes

Guess we can live with that. Might even be useful.

But what's with the gst_element_request_compatible_pad() (re-)addition? Why first remove it in an earlier patch? Why not just make it static instead?
Comment 21 Tim-Philipp Müller 2010-03-04 12:40:24 UTC
Comment on attachment 155117 [details] [review]
Remove gst_element_request_compatible_pad()

Maybe no header declares it, but it's still used further down in gstutils.c as far as I can tell. And seeing that you're re-adding it later as static function in the "Fixes-for--Wmissing-declarations--Wmissing-prototy.patch", maybe you could just make it static here?
Comment 22 Tim-Philipp Müller 2010-03-04 12:49:21 UTC
Comment on attachment 155113 [details] [review]
remove unused gst_element_default_error()

removing gst_element_default_error() should be fine seeing that it's not used anywhere and not in any header either..
Comment 23 Tim-Philipp Müller 2010-03-04 13:46:49 UTC
Comment on attachment 155126 [details] [review]
Fixes for -Wwrite-strings

Fixes for -Wwrite-strings: a bit awkward in places, but seems like a good idea to me.
Comment 24 Benjamin Otte (Company) 2010-03-04 14:10:53 UTC
(In reply to comment #20)
> (From update of attachment 155119 [details] [review])
> But what's with the gst_element_request_compatible_pad() (re-)addition? Why
> first remove it in an earlier patch? Why not just make it static instead?
>
It seems I messed that up (forgetting --amend to git commit). I had wanted to merge the two commits and just declare that function static. Will fix that when I commit.

(In reply to comment #19)
> (From update of attachment 155124 [details] [review])
> Not a big fan of this. I don't think this is useful in a GStreamer context. In
> the one or two places where it might be useful (e.g. gstvideo) it should just
> be added specifically. So -1 from me. This is just a nuisance.
>
-Wswitch-default is not a big of a problem usually - it's just "default: break" or "default: assert_not_reached(); break;", but it comes in very handy when you refactor things and add values to enums, because it will actually abort with the assertion while testing and not silently do nothing.
I agree that from a code beauty and maintenance perspective it's not necessary.
I also didn't find a bug while doing this, so it seems to get caught very well - unless you count the fact the GstStateTransition misses GST_STATE_FOO_TO_FOO transitions.
Comment 25 David Schleef 2010-03-05 07:43:42 UTC
Review of attachment 155116 [details] [review]:

I'm not impressed by all the casting that needs to be done to make signed and unsigned compares work with -Wsigned-compare.  IMO, this makes the code much more prone to errors.
Comment 26 David Schleef 2010-03-05 07:47:47 UTC
Review of attachment 155119 [details] [review]:

I don't like all the extra "#ifdef GST_DISABLE_DEPRECATED" crap.
Comment 27 David Schleef 2010-03-05 07:53:49 UTC
Comment on attachment 155124 [details] [review]
Fixes for -Wswitch-default

I happen to like -Wswitch-default, but I don't think an assertion failure is the appropriate response.  It should be g_return_if_fail() or similar.
Comment 28 Tim-Philipp Müller 2010-03-05 09:27:21 UTC
Review of attachment 155116 [details] [review]:

The common submodule change looks like an accidental git commit -a artefact.

::: gst/gstpad.c
@@ +2996,3 @@
   /* sanity check (only if caps are the same) */
+  if (G_LIKELY (newcaps == caps)
+      && G_UNLIKELY (GST_BUFFER_SIZE (*buf) < (unsigned) size))

May I suggest (unsigned int) or (guint) here instead?
Comment 29 Tim-Philipp Müller 2010-03-05 09:43:02 UTC
> I'm not impressed by all the casting that needs to be done to make signed and
> unsigned compares work with -Wsigned-compare.  IMO, this makes the code much
> more prone to errors.

I was surprised there wasn't more casting needed actually.

Something I've been wondering: is this guaranteed to work in ANSI C or dependent on compiler whims:

  if ((guint64) ts == -1)
    ...

I was under the impression that you can't rely on compilers not just optimising this away as 'comparison always false due to incompatible range', but have been too lazy to find out for sure so far. If this is the case, then -Wsigned-compare probably makes sense, no? (Even more so if current versions of gcc do what we mean in this case).
Comment 30 Benjamin Otte (Company) 2010-03-07 14:38:35 UTC
(In reply to comment #26)
> Review of attachment 155119 [details] [review]:
> 
> I don't like all the extra "#ifdef GST_DISABLE_DEPRECATED" crap.
>
Yeah, the deprecated handling (in all of GNOME) is rather bad if you want to increase the number of warning flags. I implemented the version that was both sane and required the smallest diff. There's multiple ways to solve this (in order of my preference):

1) Compile GStreamer without GST_DISABLE_DEPRECATED. That's bad because we can't check we don't use deprecated symbols ourselves.

2) in gstfoo.c, do:
#undef GST_DISBALE_DPRECATED
#include "gstfoo.h
#define GST_DISABLE_DEPRECATED
That's similarly bad (it doesn't make sure the file doesn't use the deprecated symbols) and it looks ugly, too.

3) The way in the patch, where I declare the function before implementing it.

4) Move all deprecated functions into gst_deprecated.c and #undef GST_DISABLE_DEPRECATED in there. I didn't do that because it'd have blown up the diffs. Note also that it might not work if the deprecated stuff can't be moved to a different file due to relying on static functions used by non-deprecated stuff.

5) Use G_GNUC_DEPRECATED instead of GST_DISABLE_DEPRECATED. This would also allow deprecating typedefs and public struct members. I don't know how well that method works when handling deprecated code though. And I don't know how well it's integrated into the GNOME tools (like gtk-doc).
Comment 31 Benjamin Otte (Company) 2010-03-07 14:53:47 UTC
(In reply to comment #25)
> Review of attachment 155116 [details] [review]:
> 
> I'm not impressed by all the casting that needs to be done to make signed and
> unsigned compares work with -Wsigned-compare.  IMO, this makes the code much
> more prone to errors.
>
There's in general 2 sources of errors for the required casting:
1) offsets versus differences in offsets (byte or time). It's the same bad thing as size_t vs ssize_t. I'm not aware of a way to properly handle that, but it requires particular care so enabling warnings for this makes sense I think.
We can get around the casts if we use explicit assignments instead when we want to interpret a diff as an absolute position (like I did with real_offset variable in the typefind helper).

2) Bad API design. I think all the places I've found marked this as FIXME 0.11 already, but it's unfortunately not something I can fix today, so I have to do the casts. It's especially bad if it's out variables to function calls.
Another big contributor also is the fact that we mark invalid timestamps or offsets as "(guint64) -1". We have GST_CLOCK_TIME_NONE/GST_CLOCK_TIME_IS_VALID to hide this for timestamps, but offsets only have GST_BUFFER_OFFSET_NONE. A IS_VALID() macro is missing here and the BUFFER_OFFSET_NONE name discourages use to me for anything but buffers.
Comment 32 Benjamin Otte (Company) 2010-03-07 15:03:32 UTC
(In reply to comment #27)
> (From update of attachment 155124 [details] [review])
> I happen to like -Wswitch-default, but I don't think an assertion failure is
> the appropriate response.  It should be g_return_if_fail() or similar.
>
I want something that makes developers very aware that they missed a place when adding new values. And g_assert_not_reached() matches that idea. If GStreamer doesn't disable assertions casuing crashes in releases, I could just change that to g_warn_if_reached() or whatever you think fits.
Comment 33 Stefan Sauer (gstreamer, gtkdoc dev) 2010-03-08 15:41:22 UTC
(In reply to comment #30)
non-deprecated stuff.
> 
> 5) Use G_GNUC_DEPRECATED instead of GST_DISABLE_DEPRECATED. This would also
> allow deprecating typedefs and public struct members. I don't know how well
> that method works when handling deprecated code though. And I don't know how
> well it's integrated into the GNOME tools (like gtk-doc).

gtk-doc does not know about G_GNUC_DEPRECATED.
Comment 34 Stefan Sauer (gstreamer, gtkdoc dev) 2010-03-08 15:44:06 UTC
(In reply to comment #27)
> (From update of attachment 155124 [details] [review])
> I happen to like -Wswitch-default, but I don't think an assertion failure is
> the appropriate response.  It should be g_return_if_fail() or similar.

If its not caused by external inputs we should not use g_return_{val_,}if_fail().
Comment 35 LRN 2010-03-10 17:56:44 UTC
Please revert 57d5db424c68ab5a61f33ce36ce0179eb30251ac . Apparently the other function was used on Windows (now gcc claims that gst_registry_binary_cache_write is declared implicitly).
Comment 36 Benjamin Otte (Company) 2010-03-10 19:58:18 UTC
Comment on attachment 155114 [details] [review]
registry: remove unused function

This one was reverted.
Comment 37 Benjamin Otte (Company) 2010-03-10 19:58:32 UTC
Comment on attachment 155115 [details] [review]
fixme: Add -Wno-error to avoid Bison warnings

This has been solved in a much nicer way.
Comment 38 Stefan Sauer (gstreamer, gtkdoc dev) 2011-02-28 14:42:29 UTC
What are we going to do with this? Wouldn't it make sense to push e.g. the signedness patch?
Comment 39 Tim-Philipp Müller 2011-02-28 15:26:27 UTC
Let's just close this.

I'm not so in favour of the signedness patch (or the others) - too much hassle for too little gain IMHO, esp. since we have problems with that in GStreamer all over the place not least because of things like the query API.