dbus/test break-loader.c,1.8,1.9 decode-gcov.c,1.7,1.8

Havoc Pennington hp@pdx.freedesktop.org
Sat, 11 Oct 2003 17:55:13 -0700


Update of /cvs/dbus/dbus/test
In directory pdx:/tmp/cvs-serv30697/test

Modified Files:
	break-loader.c decode-gcov.c 
Log Message:
2003-10-11  Havoc Pennington  <hp@pobox.com>

	* test/decode-gcov.c (function_solve_graph): make broken block
	graph a nonfatal error since it seems to be broken. Need to debug
	this.

	* dbus/dbus-marshal.c (_dbus_type_is_valid): new function since we
	can't just check type > INVALID < LAST anymore

	* dbus/dbus-message.c (dbus_message_get_signature): new function
	(dbus_message_has_signature): new function
	(struct DBusMessage): add signature field (right now it isn't sent
	over the wire, just generated on the fly)
	(dbus_message_copy): copy the signature, and init strings to
	proper length to avoid some reallocs
	(dbus_message_iter_init_array_iterator): return void, since it
	can't fail
	(dbus_message_iter_init_dict_iterator): return void since it can't fail
	(_dbus_message_loader_queue_messages): add silly temporary hack to
	fill in message->signature on load

	* dbus/dbus-protocol.h: change DBUS_TYPE_* values to be ASCII
	characters, so they are relatively human-readable.



Index: break-loader.c
===================================================================
RCS file: /cvs/dbus/dbus/test/break-loader.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- break-loader.c	30 Sep 2003 02:32:59 -0000	1.8
+++ break-loader.c	12 Oct 2003 00:55:11 -0000	1.9
@@ -392,6 +392,31 @@
                             extreme_ints[which]);
 }
 
+static int
+random_type (void)
+{
+  const char types[] = {
+    DBUS_TYPE_INVALID,
+    DBUS_TYPE_NIL,
+    DBUS_TYPE_BYTE,
+    DBUS_TYPE_BOOLEAN,
+    DBUS_TYPE_INT32,
+    DBUS_TYPE_UINT32,
+    DBUS_TYPE_INT64,
+    DBUS_TYPE_UINT64,
+    DBUS_TYPE_DOUBLE,
+    DBUS_TYPE_STRING,
+    DBUS_TYPE_NAMED,
+    DBUS_TYPE_ARRAY,
+    DBUS_TYPE_DICT,
+    DBUS_TYPE_OBJECT_PATH
+  };
+
+  _dbus_assert (_DBUS_N_ELEMENTS (types) == DBUS_NUMBER_OF_TYPES + 1);
+
+  return types[ random_int_in_range (0, _DBUS_N_ELEMENTS (types)) ];
+}
+
 static void
 randomly_change_one_type (const DBusString *orig_data,
                           DBusString       *mutated)
@@ -420,11 +445,9 @@
     {
       int b;
       b = _dbus_string_get_byte (mutated, i);
-      if (b > DBUS_TYPE_INVALID && b <= DBUS_TYPE_LAST)
+      if (_dbus_type_is_valid (b))
         {
-          _dbus_string_set_byte (mutated, i,
-                                 random_int_in_range (DBUS_TYPE_INVALID,
-                                                      DBUS_TYPE_LAST + 1));
+          _dbus_string_set_byte (mutated, i, random_type ());
           return;
         }
       ++i;

Index: decode-gcov.c
===================================================================
RCS file: /cvs/dbus/dbus/test/decode-gcov.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- decode-gcov.c	10 Oct 2003 03:56:30 -0000	1.7
+++ decode-gcov.c	12 Oct 2003 00:55:11 -0000	1.8
@@ -831,10 +831,10 @@
     {
       if (block_graph[i].succ_count || block_graph[i].pred_count)
         {
-          fprintf (stderr, "Block graph solved incorrectly\n");
+          fprintf (stderr, "WARNING: Block graph solved incorrectly\n");
           fprintf (stderr, " block %d has succ_count = %d pred_count = %d\n",
                    i, (int) block_graph[i].succ_count, (int) block_graph[i].pred_count);
-          exit (1);
+          fprintf (stderr, " this error reflects a bug in decode-gcov.c\n");
         }
     }
 }