DBusString *data)
{
dbus_bool_t retval;
- DBusError error;
-
+ DBusError error = DBUS_ERROR_INIT;
+
retval = FALSE;
_dbus_verbose ("Loading raw %s\n", _dbus_string_get_const_data (filename));
- dbus_error_init (&error);
if (!_dbus_file_get_contents (data, filename, &error))
{
_dbus_warn ("Could not load message file %s: %s\n",
DBusString filename;
DBusDirIter *dir;
dbus_bool_t retval;
- DBusError error;
+ DBusError error = DBUS_ERROR_INIT;
retval = FALSE;
dir = NULL;
if (!_dbus_string_init (&filename))
_dbus_assert_not_reached ("didn't allocate filename string\n");
- dbus_error_init (&error);
dir = _dbus_directory_open (&test_directory, &error);
if (dir == NULL)
{
verify_test_message (DBusMessage *message)
{
DBusMessageIter iter;
- DBusError error;
+ DBusError error = DBUS_ERROR_INIT;
dbus_int16_t our_int16;
dbus_uint16_t our_uint16;
dbus_int32_t our_int;
dbus_message_iter_init (message, &iter);
- dbus_error_init (&error);
if (!dbus_message_iter_get_args (&iter, &error,
DBUS_TYPE_INT16, &our_int16,
DBUS_TYPE_UINT16, &our_uint16,
"TestMethod"));
_dbus_assert (strcmp (dbus_message_get_path (message),
"/org/freedesktop/TestPath") == 0);
- _dbus_message_set_serial (message, 1234);
+ dbus_message_set_serial (message, 1234);
/* string length including nul byte not a multiple of 4 */
if (!dbus_message_set_sender (message, "org.foo.bar1"))
"/org/freedesktop/TestPath",
"Foo.TestInterface",
"TestMethod");
- _dbus_message_set_serial (message, 1);
+ dbus_message_set_serial (message, 1);
dbus_message_set_reply_serial (message, 5678);
v_INT16 = -0x123;
dbus_message_unref (copy);
/* Message loader test */
- _dbus_message_lock (message);
+ dbus_message_lock (message);
loader = _dbus_message_loader_new ();
/* check ref/unref */
/* Marshal and demarshal the message. */
DBusMessage *message2;
- DBusError error;
+ DBusError error = DBUS_ERROR_INIT;
char *marshalled = NULL;
int len = 0;
-
- dbus_error_init (&error);
+ char garbage_header[DBUS_MINIMUM_HEADER_SIZE] = "xxx";
if (!dbus_message_marshal (message, &marshalled, &len))
_dbus_assert_not_reached ("failed to marshal message");
_dbus_assert (len != 0);
_dbus_assert (marshalled != NULL);
+ _dbus_assert (dbus_message_demarshal_bytes_needed (marshalled, len) == len);
message2 = dbus_message_demarshal (marshalled, len, &error);
_dbus_assert (message2 != NULL);
_dbus_assert (message2 == NULL);
_dbus_assert (dbus_error_is_set (&error));
dbus_error_free (&error);
+
+ /* Bytes needed to demarshal empty message: 0 (more) */
+
+ _dbus_assert (dbus_message_demarshal_bytes_needed ("", 0) == 0);
+
+ /* Bytes needed to demarshal invalid message: -1 (error). */
+
+ _dbus_assert (dbus_message_demarshal_bytes_needed (garbage_header, DBUS_MINIMUM_HEADER_SIZE) == -1);
}
dbus_message_unref (message);