Bug 80797 - [patch] fix docmentation for DBUS_TYPE_G_UCHAR_ARRAY claiming that GByteArray is not compatible
Summary: [patch] fix docmentation for DBUS_TYPE_G_UCHAR_ARRAY claiming that GByteArray...
Status: RESOLVED NOTABUG
Alias: None
Product: dbus
Classification: Unclassified
Component: GLib (show other bugs)
Version: unspecified
Hardware: All All
: medium normal
Assignee: D-Bus Maintainers
QA Contact: D-Bus Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-02 09:43 UTC by Thomas Haller
Modified: 2015-02-09 14:09 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
documentation patch for dbus-glib (1.10 KB, patch)
2014-07-02 09:43 UTC, Thomas Haller
Details | Splinter Review

Description Thomas Haller 2014-07-02 09:43:33 UTC
Created attachment 102125 [details] [review]
documentation patch for dbus-glib

see subject.

Patch attached. Applies on current master of dbus-glib (eb14381d59ac3fdf7bbd7b75705cbf133cada399)
Comment 1 Simon McVittie 2014-09-11 11:37:29 UTC
Comment on attachment 102125 [details] [review]
documentation patch for dbus-glib

Review of attachment 102125 [details] [review]:
-----------------------------------------------------------------

> A GByteArray is implemented as GArray with element size 1

It might have the same in-memory layout, but it isn't the same GType; and I don't see anything in the GLib documentation that guarantees that you can pass a GArray* containing guchar where a GByteArray* is expected, or vice versa. So I'm reluctant to apply this.

(Also, I would actually prefer people to think "dbus-glib is awful, I'm going to stop using it"; because it is, in many other ways. Use GDBus if at all possible.)
Comment 2 Thomas Haller 2014-09-22 08:25:39 UTC
(In reply to comment #1)
> Comment on attachment 102125 [details] [review] [review]
> documentation patch for dbus-glib
> 
> Review of attachment 102125 [details] [review] [review]:
> -----------------------------------------------------------------
> 
> > A GByteArray is implemented as GArray with element size 1
> 
> It might have the same in-memory layout, but it isn't the same GType; and I
> don't see anything in the GLib documentation that guarantees that you can
> pass a GArray* containing guchar where a GByteArray* is expected, or vice
> versa. So I'm reluctant to apply this.

Correct. But GByteArray and GArray are not GObjects. Having a gpointer to such instances you must already know what you have at hand. E.g. you cannot dereference the pointer to check whether you have a G_TYPE_ARRAY or G_TYPE_BYTE_ARRAY. Hence that point doesn't matter much.


Note that glib states:

 * #GByteArray is a mutable array of bytes based on #GArray, to provide arrays
 * of bytes which grow automatically as elements are added.

also note:

GByteArray*
g_byte_array_new (void)
{
  return (GByteArray *)g_array_sized_new (FALSE, FALSE, 1, 0);
}


I would argue that glib will never change this to (re)implement GByteArray not to be effectively a GArray. Doing so might break many users. Which would be bad even when arguing that they should not rely on non-guaranteed implementation details.


> (Also, I would actually prefer people to think "dbus-glib is awful, I'm
> going to stop using it"; because it is, in many other ways. Use GDBus if at
> all possible.)

Ok.


Anyway. Feel free to reject the patch and close the bug.
Thanks.
Comment 3 Simon McVittie 2015-02-09 14:09:27 UTC
(In reply to Thomas Haller from comment #2)
> I would argue that glib will never change this to (re)implement GByteArray
> not to be effectively a GArray. Doing so might break many users. Which would
> be bad even when arguing that they should not rely on non-guaranteed
> implementation details.

Sorry, I am not convinced by this reasoning - I think it would be entirely valid for the GLib maintainers to apply that argument, so I'm not going to apply this patch unless/until the GLib documentation explicitly says that GByteArray* and (GArray-of-byte)* can be used interchangeably.

(In reply to Thomas Haller from comment #2)
> Anyway. Feel free to reject the patch and close the bug.

Done.


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.