dbus/dbus dbus-connection.c, 1.88, 1.89 dbus-internals.c, 1.39, 1.40 dbus-internals.h, 1.48, 1.49 dbus-marshal-basic.c, 1.16, 1.17 dbus-marshal-header.c, 1.3, 1.4 dbus-marshal-recursive.c, 1.41, 1.42 dbus-message.c, 1.148, 1.149 dbus-pending-call.c, 1.8, 1.9 dbus-test.c, 1.35, 1.36

Havoc Pennington hp@freedesktop.org
Sun Jan 16 16:16:31 PST 2005


Update of /cvs/dbus/dbus/dbus
In directory gabe:/tmp/cvs-serv3917/dbus

Modified Files:
	dbus-connection.c dbus-internals.c dbus-internals.h 
	dbus-marshal-basic.c dbus-marshal-header.c 
	dbus-marshal-recursive.c dbus-message.c dbus-pending-call.c 
	dbus-test.c 
Log Message:
2005-01-16  Havoc Pennington  <hp@redhat.com>

	* dbus/dbus-internals.c (_dbus_real_assert): print the function
	name the assertion failed in

	* dbus/dbus-internals.h (_dbus_return_if_fail) 
	(_dbus_return_val_if_fail): assert that the name of the function
	containing the check doesn't start with '_', since we only want to 
	use checks on public functions
	
	* dbus/dbus-connection.c (_dbus_connection_ref_unlocked): change
	checks to assertions

	* dbus/dbus-marshal-header.c (_dbus_header_set_field_basic):
	change checks to asserts for private function

	* dbus/dbus-message.c (_dbus_message_set_serial): checks
	to asserts for private function

	* dbus/dbus-marshal-recursive.c (skip_one_complete_type): remove
	broken assertion that was breaking make check
	(_dbus_type_reader_array_is_empty): remove this rather than fix
	it, was only used in assertions



Index: dbus-connection.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-connection.c,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -d -r1.88 -r1.89
--- dbus-connection.c	15 Jan 2005 07:15:38 -0000	1.88
+++ dbus-connection.c	17 Jan 2005 00:16:28 -0000	1.89
@@ -1004,8 +1004,8 @@
 DBusConnection *
 _dbus_connection_ref_unlocked (DBusConnection *connection)
 {
-  _dbus_return_val_if_fail (connection != NULL, NULL);
-  _dbus_return_val_if_fail (connection->generation == _dbus_current_generation, NULL);
+  _dbus_assert (connection != NULL);
+  _dbus_assert (connection->generation == _dbus_current_generation);
   
 #ifdef DBUS_HAVE_ATOMIC_INT
   _dbus_atomic_inc (&connection->refcount);
@@ -1442,7 +1442,7 @@
 {
   DBusPreallocatedSend *preallocated;
 
-  _dbus_return_val_if_fail (connection != NULL, NULL);
+  _dbus_assert (connection != NULL);
   
   preallocated = dbus_new (DBusPreallocatedSend, 1);
   if (preallocated == NULL)
@@ -1897,9 +1897,9 @@
   long tv_sec, tv_usec;
   DBusDispatchStatus status;
 
-  _dbus_return_val_if_fail (connection != NULL, NULL);
-  _dbus_return_val_if_fail (client_serial != 0, NULL);
-  _dbus_return_val_if_fail (timeout_milliseconds >= 0 || timeout_milliseconds == -1, FALSE);
+  _dbus_assert (connection != NULL);
+  _dbus_assert (client_serial != 0);
+  _dbus_assert (timeout_milliseconds >= 0 || timeout_milliseconds == -1);
   
   if (timeout_milliseconds == -1)
     timeout_milliseconds = _DBUS_DEFAULT_TIMEOUT_VALUE;

Index: dbus-internals.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-internals.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- dbus-internals.c	15 Jan 2005 07:15:38 -0000	1.39
+++ dbus-internals.c	17 Jan 2005 00:16:28 -0000	1.40
@@ -406,17 +406,19 @@
  * @param condition_text condition as a string
  * @param file file the assertion is in
  * @param line line the assertion is in
+ * @param func function the assertion is in
  */
 void
 _dbus_real_assert (dbus_bool_t  condition,
                    const char  *condition_text,
                    const char  *file,
-                   int          line)
+                   int          line,
+                   const char  *func)
 {
   if (_DBUS_UNLIKELY (!condition))
     {
-      _dbus_warn ("%lu: assertion failed \"%s\" file \"%s\" line %d\n",
-                  _dbus_getpid (), condition_text, file, line);
+      _dbus_warn ("%lu: assertion failed \"%s\" file \"%s\" line %d function %s\n",
+                  _dbus_getpid (), condition_text, file, line, func);
       _dbus_abort ();
     }
 }

Index: dbus-internals.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-internals.h,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- dbus-internals.h	15 Jan 2005 07:15:38 -0000	1.48
+++ dbus-internals.h	17 Jan 2005 00:16:28 -0000	1.49
@@ -100,9 +100,10 @@
 void _dbus_real_assert (dbus_bool_t  condition,
                         const char  *condition_text,
                         const char  *file,
-                        int          line);
+                        int          line,
+                        const char  *func);
 #define _dbus_assert(condition)                                         \
-  _dbus_real_assert ((condition) != 0, #condition, __FILE__, __LINE__)
+  _dbus_real_assert ((condition) != 0, #condition, __FILE__, __LINE__, _DBUS_FUNCTION_NAME)
 #endif /* !DBUS_DISABLE_ASSERT */
 
 #ifdef DBUS_DISABLE_ASSERT
@@ -122,6 +123,7 @@
 extern const char _dbus_return_if_fail_warning_format[];
 
 #define _dbus_return_if_fail(condition) do {                                            \
+   _dbus_assert ((*(const char*)_DBUS_FUNCTION_NAME) != '_');                           \
   if (!(condition)) {                                                                   \
     _dbus_warn (_dbus_return_if_fail_warning_format,                                    \
                 _dbus_getpid (), _DBUS_FUNCTION_NAME, #condition, __FILE__, __LINE__);  \
@@ -129,6 +131,7 @@
   } } while (0)
 
 #define _dbus_return_val_if_fail(condition, val) do {                                   \
+   _dbus_assert ((*(const char*)_DBUS_FUNCTION_NAME) != '_');                           \
   if (!(condition)) {                                                                   \
     _dbus_warn (_dbus_return_if_fail_warning_format,                                    \
                 _dbus_getpid (), _DBUS_FUNCTION_NAME, #condition, __FILE__, __LINE__);  \

Index: dbus-marshal-basic.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-basic.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- dbus-marshal-basic.c	16 Jan 2005 15:51:55 -0000	1.16
+++ dbus-marshal-basic.c	17 Jan 2005 00:16:28 -0000	1.17
@@ -280,7 +280,7 @@
 
   _dbus_string_init_const (&dstr, value);
 
-  _dbus_assert (_DBUS_ALIGN_VALUE (pos, 4) == pos);
+  _dbus_assert (_DBUS_ALIGN_VALUE (pos, 4) == (unsigned) pos);
   old_len = _dbus_unpack_uint32 (byte_order,
                                  _dbus_string_get_const_data_len (str, pos, 4));
 

Index: dbus-marshal-header.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-header.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- dbus-marshal-header.c	16 Jan 2005 15:51:55 -0000	1.3
+++ dbus-marshal-header.c	17 Jan 2005 00:16:28 -0000	1.4
@@ -1219,7 +1219,7 @@
                               int               type,
                               const void       *value)
 {
-  _dbus_return_val_if_fail (field <= DBUS_HEADER_FIELD_LAST, FALSE);
+  _dbus_assert (field <= DBUS_HEADER_FIELD_LAST);
 
   if (!reserve_header_padding (header))
     return FALSE;

Index: dbus-marshal-recursive.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-marshal-recursive.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- dbus-marshal-recursive.c	16 Jan 2005 15:51:55 -0000	1.41
+++ dbus-marshal-recursive.c	17 Jan 2005 00:16:28 -0000	1.42
@@ -324,12 +324,19 @@
   const unsigned char *p;
   const unsigned char *start;
 
+  _dbus_assert (type_str != NULL);
+  _dbus_assert (type_pos != NULL);
+  
   start = _dbus_string_get_const_data (type_str);
   p = start + *type_pos;
 
+  _dbus_assert (*p != DBUS_STRUCT_END_CHAR);
+  
   while (*p == DBUS_TYPE_ARRAY)
     ++p;
 
+  _dbus_assert (*p != DBUS_STRUCT_END_CHAR);
+  
   if (*p == DBUS_STRUCT_BEGIN_CHAR)
     {
       int depth;
@@ -362,8 +369,6 @@
       ++p;
     }
 
-  _dbus_assert (*p != DBUS_STRUCT_END_CHAR);
-
   *type_pos = (int) (p - start);
 }
 
@@ -849,17 +854,6 @@
 }
 
 /**
- * Checks whether an array has any elements.
- *
- * @param reader the reader
- */
-static dbus_bool_t
-_dbus_type_reader_array_is_empty (const DBusTypeReader *reader)
-{
-  return array_reader_get_array_len (reader) == 0;
-}
-
-/**
  * Get the address of the marshaled value in the data being read.  The
  * address may not be aligned; you have to align it to the type of the
  * value you want to read. Most of the demarshal routines do this for
@@ -3839,7 +3833,6 @@
               int elem;
 
               _dbus_assert (n_elements > 0);
-              _dbus_assert (!_dbus_type_reader_array_is_empty (&reader));
 
               elem = cycle;
               if (elem == 3 || elem >= n_elements) /* end of array */
@@ -3878,9 +3871,6 @@
 
   while ((t = _dbus_type_reader_get_current_type (&reader)) != DBUS_TYPE_INVALID)
     {
-      if (t == DBUS_TYPE_ARRAY)
-        _dbus_assert (_dbus_type_reader_array_is_empty (&reader));
-
       _dbus_type_reader_next (&reader);
     }
 
@@ -5428,8 +5418,6 @@
 
   if (n_copies > 0)
     {
-      _dbus_assert (!_dbus_type_reader_array_is_empty (reader));
-
       _dbus_type_reader_recurse (reader, &sub);
 
       if (realign_root == NULL && arrays_write_fixed_in_blocks &&
@@ -5478,10 +5466,6 @@
             }
         }
     }
-  else
-    {
-      _dbus_assert (_dbus_type_reader_array_is_empty (reader));
-    }
 
   return TRUE;
 }

Index: dbus-message.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-message.c,v
retrieving revision 1.148
retrieving revision 1.149
diff -u -d -r1.148 -r1.149
--- dbus-message.c	16 Jan 2005 15:51:55 -0000	1.148
+++ dbus-message.c	17 Jan 2005 00:16:28 -0000	1.149
@@ -153,9 +153,9 @@
 _dbus_message_set_serial (DBusMessage   *message,
                           dbus_uint32_t  serial)
 {
-  _dbus_return_if_fail (message != NULL);
-  _dbus_return_if_fail (!message->locked);
-  _dbus_return_if_fail (dbus_message_get_serial (message) == 0);
+  _dbus_assert (message != NULL);
+  _dbus_assert (!message->locked);
+  _dbus_assert (dbus_message_get_serial (message) == 0);
 
   _dbus_header_set_serial (&message->header, serial);
 }
@@ -4121,7 +4121,7 @@
   if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_ARRAY)
     _dbus_assert_not_reached ("Argument type not an array");
 
-  if (dbus_message_iter_get_array_type (&iter) != DBUS_TYPE_DOUBLE)
+  if (dbus_message_iter_get_element_type (&iter) != DBUS_TYPE_DOUBLE)
     _dbus_assert_not_reached ("Array type not double");
 
   dbus_message_iter_recurse (&iter, &array);
@@ -4140,7 +4140,7 @@
   if (dbus_message_iter_get_arg_type (&iter) != DBUS_TYPE_ARRAY)
     _dbus_assert_not_reached ("no array");
 
-  if (dbus_message_iter_get_array_type (&iter) != DBUS_TYPE_INT32)
+  if (dbus_message_iter_get_element_type (&iter) != DBUS_TYPE_INT32)
     _dbus_assert_not_reached ("Array type not int32");
 
   /* Empty array */

Index: dbus-pending-call.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-pending-call.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- dbus-pending-call.c	10 Aug 2004 03:07:00 -0000	1.8
+++ dbus-pending-call.c	17 Jan 2005 00:16:28 -0000	1.9
@@ -56,7 +56,7 @@
   DBusPendingCall *pending;
   DBusTimeout *timeout;
 
-  _dbus_return_val_if_fail (timeout_milliseconds >= 0 || timeout_milliseconds == -1, FALSE);
+  _dbus_assert (timeout_milliseconds >= 0 || timeout_milliseconds == -1);
   
   if (timeout_milliseconds == -1)
     timeout_milliseconds = _DBUS_DEFAULT_TIMEOUT_VALUE;

Index: dbus-test.c
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-test.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- dbus-test.c	15 Jan 2005 07:15:38 -0000	1.35
+++ dbus-test.c	17 Jan 2005 00:16:28 -0000	1.36
@@ -1,7 +1,7 @@
 /* -*- mode: C; c-file-style: "gnu" -*- */
 /* dbus-test.c  Program to run all tests
  *
- * Copyright (C) 2002, 2003  Red Hat Inc.
+ * Copyright (C) 2002, 2003, 2004, 2005  Red Hat Inc.
  *
  * Licensed under the Academic Free License version 2.1
  * 



More information about the dbus-commit mailing list