[PATCH] Add return_if_fail watch != NULL in public DBusWatch API
Christian Dywan
christian.dywan at lanedo.com
Thu Sep 23 05:38:15 PDT 2010
---
dbus/dbus-watch.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/dbus/dbus-watch.c b/dbus/dbus-watch.c
index 5acb202..8d759e5 100644
--- a/dbus/dbus-watch.c
+++ b/dbus/dbus-watch.c
@@ -496,6 +496,8 @@ _dbus_watch_set_handler (DBusWatch *watch,
int
dbus_watch_get_fd (DBusWatch *watch)
{
+ _dbus_return_val_if_fail (watch != NULL, -1);
+
return dbus_watch_get_unix_fd(watch);
}
@@ -515,6 +517,8 @@ dbus_watch_get_fd (DBusWatch *watch)
int
dbus_watch_get_unix_fd (DBusWatch *watch)
{
+ _dbus_return_val_if_fail (watch != NULL, -1);
+
/* FIXME remove #ifdef and do this on a lower level
* (watch should have set_socket and set_unix_fd and track
* which it has, and the transport should provide the
@@ -542,6 +546,8 @@ dbus_watch_get_unix_fd (DBusWatch *watch)
int
dbus_watch_get_socket (DBusWatch *watch)
{
+ _dbus_return_val_if_fail (watch != NULL, -1);
+
return watch->fd;
}
@@ -561,6 +567,7 @@ dbus_watch_get_socket (DBusWatch *watch)
unsigned int
dbus_watch_get_flags (DBusWatch *watch)
{
+ _dbus_return_val_if_fail (watch != NULL, 0);
_dbus_assert ((watch->flags & VALID_WATCH_FLAGS) == watch->flags);
return watch->flags;
@@ -576,6 +583,8 @@ dbus_watch_get_flags (DBusWatch *watch)
void*
dbus_watch_get_data (DBusWatch *watch)
{
+ _dbus_return_val_if_fail (watch != NULL, NULL);
+
return watch->data;
}
@@ -595,6 +604,8 @@ dbus_watch_set_data (DBusWatch *watch,
void *data,
DBusFreeFunction free_data_function)
{
+ _dbus_return_if_fail (watch != NULL);
+
_dbus_verbose ("Setting watch fd %d data to data = %p function = %p from data = %p function = %p\n",
dbus_watch_get_socket (watch),
data, free_data_function, watch->data, watch->free_data_function);
@@ -616,7 +627,8 @@ dbus_watch_set_data (DBusWatch *watch,
dbus_bool_t
dbus_watch_get_enabled (DBusWatch *watch)
{
- _dbus_assert (watch != NULL);
+ _dbus_return_val_if_fail (watch != NULL, FALSE);
+
return watch->enabled;
}
@@ -647,6 +659,8 @@ dbus_bool_t
dbus_watch_handle (DBusWatch *watch,
unsigned int flags)
{
+ _dbus_return_val_if_fail (watch != NULL, FALSE);
+
#ifndef DBUS_DISABLE_CHECKS
if (watch->fd < 0 || watch->flags == 0)
{
--
1.7.2.3
--MP_/5tzQHqm3g5v+R_yaHAmzmtE--
More information about the dbus
mailing list