]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
dbus-marshal-basic: Clarify what is going on when we skip an item
authorSimon McVittie <smcv@collabora.com>
Mon, 12 Sep 2022 12:29:38 +0000 (13:29 +0100)
committerSimon McVittie <smcv@collabora.com>
Fri, 7 Oct 2022 13:15:48 +0000 (14:15 +0100)
Signed-off-by: Simon McVittie <smcv@collabora.com>
dbus/dbus-marshal-basic.c

index 3a79c527e2e217bf07d11ebd3430a5f9d91d79e4..3b22aa70be06429975d47587a32341e4b6e57f1d 100644 (file)
@@ -1149,6 +1149,7 @@ _dbus_marshal_skip_basic (const DBusString      *str,
       break;
     case DBUS_TYPE_INT16:
     case DBUS_TYPE_UINT16:
+      /* Advance to the next suitably-aligned position >= *pos */
       *pos = _DBUS_ALIGN_VALUE (*pos, 2);
       *pos += 2;
       break;
@@ -1170,6 +1171,8 @@ _dbus_marshal_skip_basic (const DBusString      *str,
       {
         int len;
 
+        /* Let len be the number of bytes of string data, and advance
+         * *pos to just after the length */
         len = _dbus_marshal_read_uint32 (str, *pos, byte_order, pos);
         
         *pos += len + 1; /* length plus nul */
@@ -1211,14 +1214,21 @@ _dbus_marshal_skip_array (const DBusString  *str,
   int i;
   int alignment;
 
+  /* Advance to the next 4-byte-aligned position >= *pos */
   i = _DBUS_ALIGN_VALUE (*pos, 4);
 
+  /* Let array_len be the number of bytes of array data, and advance
+   * i to just after the length */
   array_len = _dbus_marshal_read_uint32 (str, i, byte_order, &i);
 
+  /* If the element type is more strictly-aligned than the length,
+   * advance i to the next suitably-aligned position
+   * (in other words, skip the padding) */
   alignment = _dbus_type_get_alignment (element_type);
 
   i = _DBUS_ALIGN_VALUE (i, alignment);
 
+  /* Skip the actual array data */
   *pos = i + array_len;
 }