[Telepathy] [Bug 18040] tp_list_connection_managers() (and others?) use const on complex types.

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Tue Oct 14 03:10:13 PDT 2008


http://bugs.freedesktop.org/show_bug.cgi?id=18040


Simon McVittie <simon.mcvittie at collabora.co.uk> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID




--- Comment #1 from Simon McVittie <simon.mcvittie at collabora.co.uk>  2008-10-14 03:10:08 PST ---
Er, isn't this basically the same code as examples/client/list-managers.c?
Except that the example handles errors correctly, while the code you pasted
appears to dereference @cms even if @error is non-NULL, causing a segfault
(@cms is documented as "... or %NULL on error".

list-managers.c doesn't bother declaring an equivalent of your variable "cm"
(it just uses *iter directly, since there's only one mention of it in the rest
of the function) but the following patch to make it resemble your code compiles
without warnings too. The problem is that you used "const TpConnectionManager
*" where just "TpConnectionManager *" would do.

TpConnectionManager * const * is a const pointer (pointer that you must not
free) to TpConnectionManager *, so it is correct to dereference it and assign
the result to a TpConnectionManager * variable.

diff --git a/examples/client/list-managers.c b/examples/client/list-managers.c
index 33e8aee..904e8b0 100644
--- a/examples/client/list-managers.c
+++ b/examples/client/list-managers.c
@@ -39,9 +39,10 @@ got_connection_managers (TpConnectionManager * const *cms,

       for (iter = cms; *iter != NULL; iter++)
         {
+          TpConnectionManager *cm = *iter;
           gchar *name;

-          g_object_get (*iter,
+          g_object_get (cm,
               "connection-manager", &name,
               NULL);


-- 
Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.


More information about the Telepathy mailing list