[PATCH] Add g_asserts, g_return_if_fails to volume monitor
- From: Christian Neumair <chris gnome-de org>
- To: "gnome-vfs-list gnome org" <gnome-vfs-list gnome org>
- Subject: [PATCH] Add g_asserts, g_return_if_fails to volume monitor
- Date: Thu, 28 Sep 2006 19:27:41 +0200
The attached patch adds asserts/return_if_fail statements to the GNOME
volume monitor.
--
Christian Neumair <chris gnome-de org>
Index: libgnomevfs/gnome-vfs-volume-monitor.c
===================================================================
RCS file: /cvs/gnome/gnome-vfs/libgnomevfs/gnome-vfs-volume-monitor.c,v
retrieving revision 1.18
diff -u -p -r1.18 gnome-vfs-volume-monitor.c
--- libgnomevfs/gnome-vfs-volume-monitor.c 22 Jun 2006 12:10:37 -0000 1.18
+++ libgnomevfs/gnome-vfs-volume-monitor.c 29 Aug 2006 17:27:42 -0000
@@ -370,6 +370,9 @@ _gnome_vfs_volume_monitor_find_volume_by
GList *l;
GnomeVFSVolume *vol, *ret;
+ g_assert (GNOME_IS_VFS_VOLUME_MONITOR (volume_monitor));
+ g_assert (hal_udi != NULL);
+
/* Doesn't need locks, only called internally on main thread and doesn't write */
ret = NULL;
@@ -404,6 +407,9 @@ _gnome_vfs_volume_monitor_find_drive_by_
GList *l;
GnomeVFSDrive *drive, *ret;
+ g_assert (GNOME_IS_VFS_VOLUME_MONITOR (volume_monitor));
+ g_assert (hal_udi != NULL);
+
/* Doesn't need locks, only called internally on main thread and doesn't write */
ret = NULL;
@@ -426,6 +432,9 @@ _gnome_vfs_volume_monitor_find_volume_by
GList *l;
GnomeVFSVolume *vol, *ret;
+ g_assert (GNOME_IS_VFS_VOLUME_MONITOR (volume_monitor));
+ g_assert (hal_drive_udi != NULL);
+
/* Doesn't need locks, only called internally on main thread and doesn't write */
ret = NULL;
@@ -460,6 +469,9 @@ _gnome_vfs_volume_monitor_find_drive_by_
GList *l;
GnomeVFSDrive *drive, *ret;
+ g_assert (GNOME_IS_VFS_VOLUME_MONITOR (volume_monitor));
+ g_assert (hal_drive_udi != NULL);
+
/* Doesn't need locks, only called internally on main thread and doesn't write */
ret = NULL;
@@ -483,6 +495,9 @@ _gnome_vfs_volume_monitor_find_volume_by
GList *l;
GnomeVFSVolume *vol, *ret;
+ g_assert (GNOME_IS_VFS_VOLUME_MONITOR (volume_monitor));
+ g_assert (device_path != NULL);
+
/* Doesn't need locks, only called internally on main thread and doesn't write */
ret = NULL;
@@ -530,6 +545,9 @@ _gnome_vfs_volume_monitor_find_mtab_volu
GList *l;
GnomeVFSVolume *vol, *ret;
+ g_assert (GNOME_IS_VFS_VOLUME_MONITOR (volume_monitor));
+ g_assert (activation_uri != NULL);
+
/* Doesn't need locks, only called internally on main thread and doesn't write */
ret = NULL;
@@ -552,6 +570,9 @@ _gnome_vfs_volume_monitor_find_fstab_dri
GList *l;
GnomeVFSDrive *drive, *ret;
+ g_assert (GNOME_IS_VFS_VOLUME_MONITOR (volume_monitor));
+ g_assert (activation_uri != NULL);
+
/* Doesn't need locks, only called internally on main thread and doesn't write */
ret = NULL;
@@ -574,6 +595,9 @@ _gnome_vfs_volume_monitor_find_connected
GList *l;
GnomeVFSVolume *vol, *ret;
+ g_assert (GNOME_IS_VFS_VOLUME_MONITOR (volume_monitor));
+ g_assert (id != NULL);
+
/* Doesn't need locks, only called internally on main thread and doesn't write */
ret = NULL;
@@ -611,6 +635,8 @@ gnome_vfs_volume_monitor_get_volume_by_i
GList *l;
GnomeVFSVolume *vol;
+ g_return_val_if_fail (GNOME_IS_VFS_VOLUME_MONITOR (volume_monitor), NULL);
+
g_mutex_lock (volume_monitor->priv->mutex);
for (l = volume_monitor->priv->mtab_volumes; l != NULL; l = l->next) {
@@ -665,6 +691,8 @@ gnome_vfs_volume_monitor_get_drive_by_id
GList *l;
GnomeVFSDrive *drive;
+ g_return_val_if_fail (GNOME_IS_VFS_VOLUME_MONITOR (volume_monitor), NULL);
+
g_mutex_lock (volume_monitor->priv->mutex);
for (l = volume_monitor->priv->fstab_drives; l != NULL; l = l->next) {
@@ -695,6 +723,8 @@ _gnome_vfs_volume_monitor_unmount_all (G
GList *l, *volumes;
GnomeVFSVolume *volume;
+ g_assert (GNOME_IS_VFS_VOLUME_MONITOR (volume_monitor));
+
volumes = gnome_vfs_volume_monitor_get_mounted_volumes (volume_monitor);
for (l = volumes; l != NULL; l = l->next) {
@@ -712,6 +742,8 @@ _gnome_vfs_volume_monitor_disconnect_all
GList *l, *drives;
GnomeVFSDrive *drive;
+ g_assert (GNOME_IS_VFS_VOLUME_MONITOR (volume_monitor));
+
drives = gnome_vfs_volume_monitor_get_connected_drives (volume_monitor);
for (l = drives; l != NULL; l = l->next) {
@@ -736,6 +768,9 @@ void
gnome_vfs_volume_monitor_emit_pre_unmount (GnomeVFSVolumeMonitor *volume_monitor,
GnomeVFSVolume *volume)
{
+ g_assert (GNOME_IS_VFS_VOLUME_MONITOR (volume_monitor));
+ g_assert (GNOME_IS_VFS_VOLUME (volume));
+
g_signal_emit (volume_monitor, volume_monitor_signals[VOLUME_PRE_UNMOUNT], 0, volume);
}
@@ -743,6 +778,9 @@ void
_gnome_vfs_volume_monitor_mounted (GnomeVFSVolumeMonitor *volume_monitor,
GnomeVFSVolume *volume)
{
+ g_assert (GNOME_IS_VFS_VOLUME_MONITOR (volume_monitor));
+ g_assert (GNOME_IS_VFS_VOLUME (volume));
+
gnome_vfs_volume_ref (volume);
g_mutex_lock (volume_monitor->priv->mutex);
@@ -774,6 +812,10 @@ _gnome_vfs_volume_monitor_unmounted (Gno
GnomeVFSVolume *volume)
{
GnomeVFSDrive *drive;
+
+ g_assert (GNOME_IS_VFS_VOLUME_MONITOR (volume_monitor));
+ g_assert (GNOME_IS_VFS_VOLUME (volume));
+
g_mutex_lock (volume_monitor->priv->mutex);
volume_monitor->priv->mtab_volumes = g_list_remove (volume_monitor->priv->mtab_volumes, volume);
volume_monitor->priv->server_volumes = g_list_remove (volume_monitor->priv->server_volumes, volume);
@@ -797,6 +839,9 @@ void
_gnome_vfs_volume_monitor_connected (GnomeVFSVolumeMonitor *volume_monitor,
GnomeVFSDrive *drive)
{
+ g_assert (GNOME_IS_VFS_VOLUME_MONITOR (volume_monitor));
+ g_assert (GNOME_IS_VFS_DRIVE (drive));
+
gnome_vfs_drive_ref (drive);
g_mutex_lock (volume_monitor->priv->mutex);
@@ -814,7 +859,10 @@ _gnome_vfs_volume_monitor_disconnected (
{
GList *vol_list;
GList *current_vol;
-
+
+ g_assert (GNOME_IS_VFS_VOLUME_MONITOR (volume_monitor));
+ g_assert (GNOME_IS_VFS_DRIVE (drive));
+
g_mutex_lock (volume_monitor->priv->mutex);
volume_monitor->priv->fstab_drives = g_list_remove (volume_monitor->priv->fstab_drives, drive);
drive->priv->is_connected = 0;
@@ -854,6 +902,8 @@ gnome_vfs_volume_monitor_get_mounted_vol
{
GList *ret;
+ g_return_val_if_fail (GNOME_IS_VFS_VOLUME_MONITOR (volume_monitor), NULL);
+
g_mutex_lock (volume_monitor->priv->mutex);
ret = g_list_copy (volume_monitor->priv->mtab_volumes);
ret = g_list_concat (ret,
@@ -885,6 +935,8 @@ gnome_vfs_volume_monitor_get_connected_d
{
GList *ret;
+ g_return_val_if_fail (GNOME_IS_VFS_VOLUME_MONITOR (volume_monitor), NULL);
+
g_mutex_lock (volume_monitor->priv->mutex);
ret = g_list_copy (volume_monitor->priv->fstab_drives);
g_list_foreach (ret,
@@ -931,6 +983,9 @@ _gnome_vfs_volume_monitor_uniquify_volum
int index;
char *unique_name;
+ g_assert (GNOME_IS_VFS_VOLUME_MONITOR (volume_monitor));
+ g_assert (name != NULL);
+
index = 1;
unique_name = g_strdup (name);
@@ -974,6 +1029,9 @@ _gnome_vfs_volume_monitor_uniquify_drive
int index;
char *unique_name;
+ g_assert (GNOME_IS_VFS_VOLUME_MONITOR (volume_monitor));
+ g_assert (name != NULL);
+
index = 1;
unique_name = g_strdup (name);
@@ -1015,6 +1073,9 @@ gnome_vfs_volume_monitor_get_volume_for_
dev_t device;
GList *l;
GnomeVFSVolume *volume, *res;
+
+ g_return_val_if_fail (GNOME_IS_VFS_VOLUME_MONITOR (volume_monitor), NULL);
+ g_return_val_if_fail (path != NULL, NULL);
if (g_stat (path, &statbuf) != 0)
return NULL;
[
Date Prev][
Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]