[glib] GDBus: Big-endian fixes



commit eec66b2f9424dd6db25867ee0a32e0341def15b8
Author: David Zeuthen <davidz redhat com>
Date:   Tue May 25 11:59:57 2010 -0400

    GDBus: Big-endian fixes
    
    Tested this on my Powerbook G4 12", 867MHz PowerPC G4 running Fedora
    11ish.
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 gio/gdbusmessage.c          |    8 ++++++--
 gio/tests/gdbus-threading.c |    2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/gio/gdbusmessage.c b/gio/gdbusmessage.c
index eabe171..eb93c99 100644
--- a/gio/gdbusmessage.c
+++ b/gio/gdbusmessage.c
@@ -1195,8 +1195,12 @@ g_dbus_message_bytes_needed (guchar                *blob,
     }
   else if (blob[0] == 'B')
     {
-      /* TODO */
-      g_assert_not_reached ();
+      /* core header (12 bytes) + ARRAY of STRUCT of (BYTE,VARIANT) */
+      ret = 12 + 4 + GUINT32_FROM_BE (((guint32 *) blob)[3]);
+      /* round up so it's a multiple of 8 */
+      ret = 8 * ((ret + 7)/8);
+      /* finally add the body size */
+      ret += GUINT32_FROM_BE (((guint32 *) blob)[1]);
     }
   else
     {
diff --git a/gio/tests/gdbus-threading.c b/gio/tests/gdbus-threading.c
index 6a4e82c..24e0704 100644
--- a/gio/tests/gdbus-threading.c
+++ b/gio/tests/gdbus-threading.c
@@ -445,7 +445,7 @@ on_proxy_appeared (GDBusConnection *connection,
 
       /* elapsed_msec should be 4000 msec +/- change for overhead/inaccuracy */
       g_assert_cmpint (elapsed_msec, >=, 3950);
-      g_assert_cmpint (elapsed_msec,  <, 5000);
+      g_assert_cmpint (elapsed_msec,  <, 6000);
 
       g_print (" ");
     }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]