Bug 35952 - any argument with the ReturnVal annotation is treated as if it came first
Summary: any argument with the ReturnVal annotation is treated as if it came first
Status: RESOLVED FIXED
Alias: None
Product: dbus
Classification: Unclassified
Component: GLib (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Simon McVittie
QA Contact: John (J5) Palmieri
URL: http://cgit.freedesktop.org/~smcv/dbu...
Whiteboard: review+
Keywords: patch
Depends on:
Blocks:
 
Reported: 2011-04-04 05:38 UTC by Simon McVittie
Modified: 2011-06-02 05:10 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
dbus-binding-tool: forbid ReturnVal annotation after the first OUT <arg> (2.33 KB, patch)
2011-04-04 05:55 UTC, Simon McVittie
Details | Splinter Review

Description Simon McVittie 2011-04-04 05:38:14 UTC
I happened to notice this while looking at Bug #35767.

Consider this (rather contrived) C prototype:

    /**
     * get_text:
     * @lang: (out) (allow-none): the ISO language code for the text
     * @wordcount: (out) (allow-none): the word-count for the text
     * @error: (out) (allow-none): used to raise an exception
     * 
     * Returns: (transfer full): some text, or %NULL on errors
     */
    gchar *get_text (gchar **lang, guint *wordcount, GError **error);

Suppose we want to use it as an implementation of this D-Bus method:

    GetText () -> (s: lang, u: wordcount, s: text)

The @text argument would be the third <arg> element, and would have the ...GLib.ReturnVal="error" annotation.

However, invoke_object_method always serializes the ReturnVal first:

    /* First, append the return value, unless it's synthetic */

so it would actually return (s: text, s: lang, u: wordcount) whenever it was successful!

Since this has never worked properly, I'd be inclined to just "fix" this by making dbus-binding-tool forbid the use of ReturnVal unless it's on the first "out" <arg>. The only d-b-t reimplementations I'm aware of are in telepathy-glib, and they don't support ReturnVal anyway.
Comment 1 Simon McVittie 2011-04-04 05:55:09 UTC
Created attachment 45221 [details] [review]
dbus-binding-tool: forbid ReturnVal annotation after the first OUT <arg>

It has never actually worked correctly (invoke_object_method would always
treat the ReturnVal as if it had been the first OUT argument), so let's
only allow the situation that worked in practice.
Comment 2 Will Thompson 2011-06-01 09:43:52 UTC
This looks fine.
Comment 3 Simon McVittie 2011-06-02 05:10:33 UTC
Fixed in 0.94


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.