Summary: | [patch] fix docmentation for DBUS_TYPE_G_UCHAR_ARRAY claiming that GByteArray is not compatible | ||
---|---|---|---|
Product: | dbus | Reporter: | Thomas Haller <thaller> |
Component: | GLib | Assignee: | D-Bus Maintainers <dbus> |
Status: | RESOLVED NOTABUG | QA Contact: | D-Bus Maintainers <dbus> |
Severity: | normal | ||
Priority: | medium | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | All | ||
Whiteboard: | |||
i915 platform: | i915 features: | ||
Attachments: | documentation patch for dbus-glib |
Description
Thomas Haller
2014-07-02 09:43:33 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.) (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. (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.