A couple of fixes
Olivier Andrieu
oliv__a at users.sourceforge.net
Fri May 14 02:58:05 PDT 2004
Hi,
two small patches:
- in configure.in HAVE_ABSTRACT_SOCKETS is defined to 0 when the
platform does not have abstract sockets: it should be undefined.
- dbus_connection_list_registered has a bug: if /foo/bar is registered
but not /foo, dbus_connection_list_registered("/foo") will return
nothing (it should be returning "bar").
--
Olivier
-------------- next part --------------
Index: dbus/dbus-object-tree.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-object-tree.c,v
retrieving revision 1.4
diff -u -r1.4 dbus-object-tree.c
--- a/dbus/dbus-object-tree.c 2 Dec 2003 10:44:21 -0000 1.4
+++ b/dbus/dbus-object-tree.c 14 May 2004 09:49:04 -0000
@@ -344,6 +344,16 @@
}
static DBusObjectSubtree*
+lookup_subtree (DBusObjectTree *tree,
+ const char **path)
+{
+#if VERBOSE_FIND
+ _dbus_verbose ("Looking for subtree\n");
+#endif
+ return find_subtree_recurse (tree->root, path, FALSE, FALSE, NULL);
+}
+
+static DBusObjectSubtree*
find_handler (DBusObjectTree *tree,
const char **path)
{
@@ -553,12 +563,10 @@
*child_entries = NULL;
- subtree = find_subtree (tree, parent_path, NULL);
+ subtree = lookup_subtree (tree, parent_path);
if (subtree == NULL)
{
retval = dbus_new0 (char *, 1);
- if (retval == NULL)
- goto out;
}
else
{
@@ -566,8 +574,7 @@
retval = dbus_new0 (char*, subtree->n_subtrees + 1);
if (retval == NULL)
goto out;
- i = 0;
- while (i < subtree->n_subtrees)
+ for (i = 0; i < subtree->n_subtrees; ++i)
{
retval[i] = _dbus_strdup (subtree->subtrees[i]->name);
if (retval[i] == NULL)
@@ -576,7 +583,6 @@
retval = NULL;
goto out;
}
- ++i;
}
}
@@ -1143,6 +1149,15 @@
return FALSE;
}
+static size_t
+string_array_length (char **array)
+{
+ size_t i;
+ for (i = 0; array[i]; i++) ;
+ return i;
+}
+
+
static dbus_bool_t
object_tree_test_iteration (void *data)
{
@@ -1287,6 +1302,46 @@
_dbus_assert (find_handler (tree, path7) != tree->root);
_dbus_assert (find_handler (tree, path8) != tree->root);
+ /* test the list_registered function */
+
+ {
+ const char *root[] = { NULL };
+ char **child_entries;
+ int nb;
+
+ _dbus_object_tree_list_registered_unlocked (tree, path1, &child_entries);
+ if (child_entries != NULL)
+ {
+ nb = string_array_length (child_entries);
+ _dbus_assert (nb == 1);
+ dbus_free_string_array (child_entries);
+ }
+
+ _dbus_object_tree_list_registered_unlocked (tree, path2, &child_entries);
+ if (child_entries != NULL)
+ {
+ nb = string_array_length (child_entries);
+ _dbus_assert (nb == 2);
+ dbus_free_string_array (child_entries);
+ }
+
+ _dbus_object_tree_list_registered_unlocked (tree, path8, &child_entries);
+ if (child_entries != NULL)
+ {
+ nb = string_array_length (child_entries);
+ _dbus_assert (nb == 0);
+ dbus_free_string_array (child_entries);
+ }
+
+ _dbus_object_tree_list_registered_unlocked (tree, root, &child_entries);
+ if (child_entries != NULL)
+ {
+ nb = string_array_length (child_entries);
+ _dbus_assert (nb == 3);
+ dbus_free_string_array (child_entries);
+ }
+ }
+
/* Check that destroying tree calls unregister funcs */
_dbus_object_tree_unref (tree);
Index: configure.in
===================================================================
RCS file: /cvs/dbus/dbus/configure.in,v
retrieving revision 1.82
diff -u -r1.82 configure.in
--- a/configure.in 13 Apr 2004 11:39:41 -0000 1.82
+++ b/configure.in 14 May 2004 09:49:05 -0000
@@ -557,15 +557,12 @@
fi
if test x$have_abstract_sockets = xyes ; then
- abstract_sockets=1
DBUS_PATH_OR_ABSTRACT=abstract
+ AC_DEFINE(HAVE_ABSTRACT_SOCKETS,1,[Have abstract socket namespace])
else
- abstract_sockets=0
DBUS_PATH_OR_ABSTRACT=path
fi
-AC_DEFINE_UNQUOTED(HAVE_ABSTRACT_SOCKETS, $abstract_sockets, [Have abstract socket namespace])
-
# this is used in addresses to prefer abstract, e.g.
# unix:path=/foo or unix:abstract=/foo
AC_SUBST(DBUS_PATH_OR_ABSTRACT)
Index: ChangeLog
===================================================================
RCS file: /cvs/dbus/dbus/ChangeLog,v
retrieving revision 1.484
diff -u -r1.484 ChangeLog
--- a/ChangeLog 11 May 2004 18:31:33 -0000 1.484
+++ b/ChangeLog 14 May 2004 09:49:11 -0000
@@ -1,3 +1,13 @@
+2004-05-14 Olivier Andrieu <oliv__a at users.sourceforge.net>
+
+ * dbus/dbus-object-tree.c
+ (_dbus_object_tree_list_registered_unlock, lookup_subtree): return
+ children even if the requested path isn't registered.
+ (object_tree_test_iteration): test object_tree_list_registered.
+
+ * configure.in: undefine HAVE_ABSTRACT_SOCKETS instead of defining
+ it to 0.
+
2004-05-11 John (J5) Palmieri <johnp at redhat.com>:
* doc/dbus-specification.xml: Added a "Required" column to the
More information about the dbus
mailing list