From: Christian Dywan Date: Thu, 23 Sep 2010 12:38:15 +0000 (+0200) Subject: Add return_if_fail watch != NULL in public DBusWatch API X-Git-Tag: dbus-1.4.1~51 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=63d3e3d9d4ebc808eaa1b12a0e4f603c04854e9f;p=thirdparty%2Fdbus.git Add return_if_fail watch != NULL in public DBusWatch API Reviewed-by: Havoc Pennington Signed-off-by: Will Thompson --- diff --git a/dbus/dbus-watch.c b/dbus/dbus-watch.c index 5acb2020d..8d759e5e3 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) {