]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
dbus-marshal-recursive.h: reduce padding in DBusType{Reader,Writer}
authorAlex Richardson <arichardson@FreeBSD.org>
Fri, 12 Aug 2022 10:34:06 +0000 (10:34 +0000)
committerSimon McVittie <smcv@collabora.com>
Wed, 21 Sep 2022 11:35:05 +0000 (11:35 +0000)
When building for Arm Morello (where pointers are 16 bytes), I hit the
static assertion that sizeof (DBusMessageRealIter) <= sizeof (DBusMessageIter)
inside _dbus_message_iter_init_common() otherwise. This can be fixed by
moving the pointers to the beginning of the struct to remove padding.

dbus/dbus-marshal-recursive.h

index c3b96819d5edcb39ca2148962180c841a5e5f2c9..5822e058fb8f525b2f03714de52925148566fbd4 100644 (file)
@@ -38,18 +38,19 @@ typedef struct DBusArrayLenFixup   DBusArrayLenFixup;
  */
 struct DBusTypeReader
 {
+  const DBusTypeReaderClass *klass; /**< the vtable for the reader */
+  const DBusString *type_str;   /**< string containing signature of block */
+  const DBusString *value_str;  /**< string containing values of block */
+
   dbus_uint32_t byte_order : 8; /**< byte order of the block */
 
   dbus_uint32_t finished : 1;   /**< marks we're at end iterator for cases
                                  * where we don't have another way to tell
                                  */
   dbus_uint32_t array_len_offset : 3; /**< bytes back from start_pos that len ends */
-  const DBusString *type_str;   /**< string containing signature of block */
   int type_pos;                 /**< current position in signature */
-  const DBusString *value_str;  /**< string containing values of block */
   int value_pos;                /**< current position in values */
 
-  const DBusTypeReaderClass *klass; /**< the vtable for the reader */
   union
   {
     struct {
@@ -63,6 +64,8 @@ struct DBusTypeReader
  */
 struct DBusTypeWriter
 {
+  DBusString *type_str; /**< where to write typecodes (or read type expectations) */
+  DBusString *value_str; /**< where to write values */
   dbus_uint32_t byte_order : 8;            /**< byte order to write values with */
 
   dbus_uint32_t container_type : 8;        /**< what are we inside? (e.g. struct, variant, array) */
@@ -71,9 +74,7 @@ struct DBusTypeWriter
 
   dbus_uint32_t enabled : 1; /**< whether to write values */
 
-  DBusString *type_str; /**< where to write typecodes (or read type expectations) */
   int type_pos;         /**< current pos in type_str */
-  DBusString *value_str; /**< where to write values */
   int value_pos;         /**< next position to write */
 
   union