GNOME Bugzilla – Bug 696108
gdbus-codegen: avoid warnings in generated code
Last modified: 2018-02-16 12:56:20 UTC
Created attachment 239206 [details] [review] Avoid warnings due to unused parameters Hi, when generating code from XML like <node> <interface name='org.gnome.SessionManager.Presence'> <property name='status' type='u' access='readwrite'/> <signal name='StatusChanged'> <arg type='u' direction='out'/> </signal> </interface> </node> with gdbus-codegen \ --generate-c-code sessionmanager-presence-generated \ org.gnome.SessionManager.Presence.xml and building the resulting code with -Wunused-parameter there are several warnings due to unused variables. Attached patch fixes this. Does this make any sense or am I just using gdbus-codegen the wrong way?
Created attachment 239593 [details] [review] Updated patch that also handles --c-generate-object-manager
Created attachment 239646 [details] [review] Use C99 initializers for GDBusInterfaceVTable to avoid a missing initializer warning This patch (on top of the other) handles warnings issued when using -Wmissing-field-initializers
Review of attachment 239646 [details] [review]: Unfortunately the GTK+ stack at least needs to compile with C89 for MSVC, so we can't generate code that uses C99. Can't we initialize the padding fields instead?
Created attachment 239648 [details] [review] Init padding to NULL to avoid a missing initializer warning Avoid C99 initializers since MSVC needs C89 as pointed out by Colin
Review of attachment 239648 [details] [review]: Looks fine, just one note: Can you link back to the bug in the commit message? See https://live.gnome.org/GnomeLove/SubmittingPatches
Review of attachment 239648 [details] [review]: Comitted. Just after pushing I realized we're in realize freeze, hopefully that's not a problem.
Created attachment 239681 [details] [review] Avoid warnings when the generated client code is built with -Wunused-parameter Update -Wunused-parameter patch to contain bugzilla reference too
Created attachment 239685 [details] [review] codegen: move G_DEFINE_INTERFACE{,_WITH_CODE} before _default_init Avoid warnings when building with -Wredundant-decls. These three patches together make building with -Wall -Wformat -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wextra -Wshadow -Wcast-align -Wwrite-strings -Waggregate-return -Winline -Wredundant-decls -Wno-sign-compare -Wp,-D_FORTIFY_SOURCE=2 warning free for me on Linux.
Any chance to get a comment on the other two patches?
Review of attachment 239681 [details] [review]: That's a pretty heavy-handed warning to use, but this makes sense to me, yes.
Review of attachment 239685 [details] [review]: Yep, looks right.
Both pushed. Thanks a lot for the review!
*** Bug 693697 has been marked as a duplicate of this bug. ***