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 696108 - gdbus-codegen: avoid warnings in generated code
gdbus-codegen: avoid warnings in generated code
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gdbus
2.35.x
Other Linux
: Normal normal
: ---
Assigned To: David Zeuthen (not reading bugmail)
gtkdev
: 693697 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2013-03-18 21:46 UTC by Guido Günther
Modified: 2018-02-16 12:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Avoid warnings due to unused parameters (6.27 KB, patch)
2013-03-18 21:46 UTC, Guido Günther
none Details | Review
Updated patch that also handles --c-generate-object-manager (9.92 KB, patch)
2013-03-23 00:26 UTC, Guido Günther
none Details | Review
Use C99 initializers for GDBusInterfaceVTable to avoid a missing initializer warning (1.72 KB, patch)
2013-03-23 21:08 UTC, Guido Günther
reviewed Details | Review
Init padding to NULL to avoid a missing initializer warning (1.44 KB, patch)
2013-03-23 21:49 UTC, Guido Günther
committed Details | Review
Avoid warnings when the generated client code is built with -Wunused-parameter (9.96 KB, patch)
2013-03-24 15:32 UTC, Guido Günther
committed Details | Review
codegen: move G_DEFINE_INTERFACE{,_WITH_CODE} before _default_init (3.41 KB, patch)
2013-03-24 16:18 UTC, Guido Günther
committed Details | Review

Description Guido Günther 2013-03-18 21:46:28 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?
Comment 1 Guido Günther 2013-03-23 00:26:44 UTC
Created attachment 239593 [details] [review]
Updated patch that also handles --c-generate-object-manager
Comment 2 Guido Günther 2013-03-23 21:08:34 UTC
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
Comment 3 Colin Walters 2013-03-23 21:28:04 UTC
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?
Comment 4 Guido Günther 2013-03-23 21:49:32 UTC
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
Comment 5 Colin Walters 2013-03-24 14:31:35 UTC
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
Comment 6 Guido Günther 2013-03-24 15:29:58 UTC
Review of attachment 239648 [details] [review]:

Comitted. Just after pushing I realized we're in realize freeze, hopefully that's not a problem.
Comment 7 Guido Günther 2013-03-24 15:32:29 UTC
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
Comment 8 Guido Günther 2013-03-24 16:18:58 UTC
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.
Comment 9 Guido Günther 2013-04-02 10:17:32 UTC
Any chance to get a comment on the other two patches?
Comment 10 Colin Walters 2013-04-02 10:38:09 UTC
Review of attachment 239681 [details] [review]:

That's a pretty heavy-handed warning to use, but this makes sense to me, yes.
Comment 11 Colin Walters 2013-04-02 10:41:54 UTC
Review of attachment 239685 [details] [review]:

Yep, looks right.
Comment 12 Guido Günther 2013-04-02 19:55:09 UTC
Both pushed. Thanks a lot for the review!
Comment 13 Philip Withnall 2018-02-16 12:56:20 UTC
*** Bug 693697 has been marked as a duplicate of this bug. ***