[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 08:21:15 PDT 2008
http://bugs.freedesktop.org/show_bug.cgi?id=18040
--- Comment #2 from Murray Cumming <murrayc at murrayc.com> 2008-10-14 08:21:15 PST ---
(In reply to comment #1)
> 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".
I left the error checking out on purpose to demonstrate more clearly the
problem with const. Of course.
> 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 *,
I thought that would be
TpConnectionManager * * const
because you can generally read pointer syntax backwards, but as I've said
elsewhere pointer to pointer syntax is horrible and should be avoided. At the
least, typedefs should be used to clarify it.
I tried it and you seem to be right. Sorry. Thanks.
--
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