From a043325ec10c7c6ef754f07f6d614ca5518305f0 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 21 Jan 2008 05:12:16 +0000 Subject: [PATCH] Coding style fixes svn path=/trunk/; revision=6337 --- gio/ChangeLog | 6 +++++ gio/inotify/ginotifydirectorymonitor.c | 14 +++++----- gio/inotify/ginotifyfilemonitor.c | 18 ++++++------- gio/inotify/inotify-helper.c | 7 ++--- gio/inotify/inotify-kernel.c | 49 +++++++++++++++++++++------------- gio/inotify/inotify-missing.c | 4 +-- gio/inotify/inotify-path.c | 34 ++++++++++++++--------- gio/inotify/inotify-sub.c | 12 +++++---- 8 files changed, 88 insertions(+), 56 deletions(-) diff --git a/gio/ChangeLog b/gio/ChangeLog index 03c13b7..f5ddeae 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,5 +1,11 @@ 2008-01-20 Matthias Clasen + * inotify/*.c: Coding style fixes. + * inotify/inotify-missing.c: Use g_timeout_add_seconds + for the 1/4 Hz timer. + +2008-01-20 Matthias Clasen + * gfile.c: * gfilemonitor.[hc]: * gmemoryinputstream.c: diff --git a/gio/inotify/ginotifydirectorymonitor.c b/gio/inotify/ginotifydirectorymonitor.c index 1f281c8..eb90534 100644 --- a/gio/inotify/ginotifydirectorymonitor.c +++ b/gio/inotify/ginotifydirectorymonitor.c @@ -50,7 +50,7 @@ g_inotify_directory_monitor_finalize (GObject *object) GInotifyDirectoryMonitor *inotify_monitor = G_INOTIFY_DIRECTORY_MONITOR (object); inotify_sub *sub = inotify_monitor->sub; - if (inotify_monitor->sub) + if (sub) { _ih_sub_cancel (sub); _ih_sub_free (sub); @@ -124,7 +124,6 @@ g_inotify_directory_monitor_class_init (GInotifyDirectoryMonitorClass* klass) static void g_inotify_directory_monitor_init (GInotifyDirectoryMonitor* monitor) { - } static gboolean @@ -133,11 +132,12 @@ g_inotify_directory_monitor_cancel (GFileMonitor* monitor) GInotifyDirectoryMonitor *inotify_monitor = G_INOTIFY_DIRECTORY_MONITOR (monitor); inotify_sub *sub = inotify_monitor->sub; - if (sub) { - _ih_sub_cancel (sub); - _ih_sub_free (sub); - inotify_monitor->sub = NULL; - } + if (sub) + { + _ih_sub_cancel (sub); + _ih_sub_free (sub); + inotify_monitor->sub = NULL; + } if (G_FILE_MONITOR_CLASS (g_inotify_directory_monitor_parent_class)->cancel) (*G_FILE_MONITOR_CLASS (g_inotify_directory_monitor_parent_class)->cancel) (monitor); diff --git a/gio/inotify/ginotifyfilemonitor.c b/gio/inotify/ginotifyfilemonitor.c index b731269..7e460f2 100644 --- a/gio/inotify/ginotifyfilemonitor.c +++ b/gio/inotify/ginotifyfilemonitor.c @@ -52,7 +52,7 @@ g_inotify_file_monitor_finalize (GObject *object) GInotifyFileMonitor *inotify_monitor = G_INOTIFY_FILE_MONITOR (object); inotify_sub *sub = inotify_monitor->sub; - if (inotify_monitor->sub) + if (sub) { _ih_sub_cancel (sub); _ih_sub_free (sub); @@ -76,8 +76,8 @@ g_inotify_file_monitor_finalize (GObject *object) } static GObject * -g_inotify_file_monitor_constructor (GType type, - guint n_construct_properties, +g_inotify_file_monitor_constructor (GType type, + guint n_construct_properties, GObjectConstructParam *construct_properties) { GObject *obj; @@ -142,7 +142,6 @@ g_inotify_file_monitor_class_init (GInotifyFileMonitorClass* klass) static void g_inotify_file_monitor_init (GInotifyFileMonitor* monitor) { - } static gboolean @@ -151,11 +150,12 @@ g_inotify_file_monitor_cancel (GFileMonitor* monitor) GInotifyFileMonitor *inotify_monitor = G_INOTIFY_FILE_MONITOR (monitor); inotify_sub *sub = inotify_monitor->sub; - if (sub) { - _ih_sub_cancel (sub); - _ih_sub_free (sub); - inotify_monitor->sub = NULL; - } + if (sub) + { + _ih_sub_cancel (sub); + _ih_sub_free (sub); + inotify_monitor->sub = NULL; + } if (G_FILE_MONITOR_CLASS (g_inotify_file_monitor_parent_class)->cancel) (*G_FILE_MONITOR_CLASS (g_inotify_file_monitor_parent_class)->cancel) (monitor); diff --git a/gio/inotify/inotify-helper.c b/gio/inotify/inotify-helper.c index 17ccd99..34d7f61 100644 --- a/gio/inotify/inotify-helper.c +++ b/gio/inotify/inotify-helper.c @@ -116,7 +116,7 @@ _ih_startup (void) * Adds a subscription to be monitored. */ gboolean -_ih_sub_add (inotify_sub * sub) +_ih_sub_add (inotify_sub *sub) { G_LOCK (inotify_lock); @@ -131,7 +131,7 @@ _ih_sub_add (inotify_sub * sub) * Cancels a subscription which was being monitored. */ gboolean -_ih_sub_cancel (inotify_sub * sub) +_ih_sub_cancel (inotify_sub *sub) { G_LOCK (inotify_lock); @@ -150,7 +150,8 @@ _ih_sub_cancel (inotify_sub * sub) static void -ih_event_callback (ik_event_t *event, inotify_sub *sub) +ih_event_callback (ik_event_t *event, + inotify_sub *sub) { gchar *fullpath; GFileMonitorEvent eflags; diff --git a/gio/inotify/inotify-kernel.c b/gio/inotify/inotify-kernel.c index 6735c45..4b6381a 100644 --- a/gio/inotify/inotify-kernel.c +++ b/gio/inotify/inotify-kernel.c @@ -95,7 +95,7 @@ typedef struct ik_event_internal { */ static gboolean ik_source_prepare (GSource *source, - gint *timeout) + gint *timeout) { return FALSE; } @@ -146,7 +146,8 @@ ik_source_check (GSource *source) goto do_read; /* With each successive iteration, the minimum rate for - * further sleep doubles. */ + * further sleep doubles. + */ if (pending-prev_pending < PENDING_MARGINAL_COST (pending_count)) goto do_read; @@ -176,9 +177,9 @@ do_read: } static gboolean -ik_source_dispatch (GSource *source, - GSourceFunc callback, - gpointer user_data) +ik_source_dispatch (GSource *source, + GSourceFunc callback, + gpointer user_data) { if (callback) return callback (user_data); @@ -215,7 +216,7 @@ gboolean _ik_startup (void (*cb)(ik_event_t *event)) g_io_channel_set_encoding (inotify_read_ioc, NULL, NULL); g_io_channel_set_flags (inotify_read_ioc, G_IO_FLAG_NONBLOCK, NULL); - source = g_source_new (&ik_source_funcs, sizeof(GSource)); + source = g_source_new (&ik_source_funcs, sizeof (GSource)); g_source_add_poll (source, &ik_poll_fd); g_source_set_callback (source, ik_read_callback, NULL, NULL); g_source_attach (source, NULL); @@ -248,7 +249,7 @@ static ik_event_t * ik_event_new (char *buffer) { struct inotify_event *kevent = (struct inotify_event *)buffer; - ik_event_t *event = g_new0(ik_event_t,1); + ik_event_t *event = g_new0 (ik_event_t, 1); g_assert (buffer); @@ -265,9 +266,11 @@ ik_event_new (char *buffer) } ik_event_t * -_ik_event_new_dummy (const char *name, gint32 wd, guint32 mask) +_ik_event_new_dummy (const char *name, + gint32 wd, + guint32 mask) { - ik_event_t *event = g_new0 (ik_event_t,1); + ik_event_t *event = g_new0 (ik_event_t, 1); event->wd = wd; event->mask = mask; event->cookie = 0; @@ -291,7 +294,9 @@ _ik_event_free (ik_event_t *event) } gint32 -_ik_watch (const char *path, guint32 mask, int *err) +_ik_watch (const char *path, + guint32 mask, + int *err) { gint32 wd = -1; @@ -314,7 +319,8 @@ _ik_watch (const char *path, guint32 mask, int *err) } int -_ik_ignore(const char *path, gint32 wd) +_ik_ignore (const char *path, + gint32 wd) { g_assert (wd >= 0); g_assert (inotify_instance_fd >= 0); @@ -330,7 +336,8 @@ _ik_ignore(const char *path, gint32 wd) } void -_ik_move_stats (guint32 *matches, guint32 *misses) +_ik_move_stats (guint32 *matches, + guint32 *misses) { if (matches) *matches = ik_move_matches; @@ -421,7 +428,8 @@ _ik_mask_to_string (guint32 mask) static void -ik_read_events (gsize *buffer_size_out, gchar **buffer_out) +ik_read_events (gsize *buffer_size_out, + gchar **buffer_out) { static gchar *buffer = NULL; static gsize buffer_size; @@ -480,7 +488,8 @@ ik_read_callback (gpointer user_data) } static gboolean -g_timeval_lt (GTimeVal *val1, GTimeVal *val2) +g_timeval_lt (GTimeVal *val1, + GTimeVal *val2) { if (val1->tv_sec < val2->tv_sec) return TRUE; @@ -496,13 +505,15 @@ g_timeval_lt (GTimeVal *val1, GTimeVal *val2) } static gboolean -g_timeval_eq (GTimeVal *val1, GTimeVal *val2) +g_timeval_eq (GTimeVal *val1, + GTimeVal *val2) { return (val1->tv_sec == val2->tv_sec) && (val1->tv_usec == val2->tv_usec); } static void -ik_pair_events (ik_event_internal_t *event1, ik_event_internal_t *event2) +ik_pair_events (ik_event_internal_t *event1, + ik_event_internal_t *event2) { g_assert (event1 && event2); /* We should only be pairing events that have the same cookie */ @@ -521,7 +532,8 @@ ik_pair_events (ik_event_internal_t *event1, ik_event_internal_t *event2) } static void -ik_event_add_microseconds (ik_event_internal_t *event, glong ms) +ik_event_add_microseconds (ik_event_internal_t *event, + glong ms) { g_assert (event); g_time_val_add (&event->hold_until, ms); @@ -549,7 +561,8 @@ ik_event_ready (ik_event_internal_t *event) } static void -ik_pair_moves (gpointer data, gpointer user_data) +ik_pair_moves (gpointer data, + gpointer user_data) { ik_event_internal_t *event = (ik_event_internal_t *)data; diff --git a/gio/inotify/inotify-missing.c b/gio/inotify/inotify-missing.c index 96126b3..d19332a 100644 --- a/gio/inotify/inotify-missing.c +++ b/gio/inotify/inotify-missing.c @@ -28,7 +28,7 @@ #include "inotify-missing.h" #include "inotify-path.h" -#define SCAN_MISSING_TIME 4000 /* 1/4 Hz */ +#define SCAN_MISSING_TIME 4 /* 1/4 Hz */ static gboolean im_debug_enabled = FALSE; #define IM_W if (im_debug_enabled) g_warning @@ -71,7 +71,7 @@ _im_add (inotify_sub *sub) if (!scan_missing_running) { scan_missing_running = TRUE; - g_timeout_add (SCAN_MISSING_TIME, im_scan_missing, NULL); + g_timeout_add_seconds (SCAN_MISSING_TIME, im_scan_missing, NULL); } } diff --git a/gio/inotify/inotify-path.c b/gio/inotify/inotify-path.c index 76fc06d..ffdfa81 100644 --- a/gio/inotify/inotify-path.c +++ b/gio/inotify/inotify-path.c @@ -112,14 +112,16 @@ _ip_startup (void (*cb)(ik_event_t *event, inotify_sub *sub)) } static void -ip_map_path_dir (const char *path, ip_watched_dir_t *dir) +ip_map_path_dir (const char *path, + ip_watched_dir_t *dir) { g_assert (path && dir); g_hash_table_insert (path_dir_hash, dir->path, dir); } static void -ip_map_sub_dir (inotify_sub *sub, ip_watched_dir_t *dir) +ip_map_sub_dir (inotify_sub *sub, + ip_watched_dir_t *dir) { /* Associate subscription and directory */ g_assert (dir && sub); @@ -128,7 +130,8 @@ ip_map_sub_dir (inotify_sub *sub, ip_watched_dir_t *dir) } static void -ip_map_wd_dir (gint32 wd, ip_watched_dir_t *dir) +ip_map_wd_dir (gint32 wd, + ip_watched_dir_t *dir) { GList *dir_list; @@ -161,7 +164,7 @@ _ip_start_watching (inotify_sub *sub) wd = _ik_watch (sub->dirname, IP_INOTIFY_MASK|IN_ONLYDIR, &err); if (wd < 0) { - IP_W("Failed\n"); + IP_W ("Failed\n"); return FALSE; } else @@ -182,14 +185,16 @@ _ip_start_watching (inotify_sub *sub) } static void -ip_unmap_path_dir (const char *path, ip_watched_dir_t *dir) +ip_unmap_path_dir (const char *path, + ip_watched_dir_t *dir) { g_assert (path && dir); g_hash_table_remove (path_dir_hash, dir->path); } static void -ip_unmap_wd_dir (gint32 wd, ip_watched_dir_t *dir) +ip_unmap_wd_dir (gint32 wd, + ip_watched_dir_t *dir) { GList *dir_list = g_hash_table_lookup (wd_dir_hash, GINT_TO_POINTER (wd)); @@ -216,7 +221,8 @@ ip_unmap_wd (gint32 wd) } static void -ip_unmap_sub_dir (inotify_sub *sub, ip_watched_dir_t *dir) +ip_unmap_sub_dir (inotify_sub *sub, + ip_watched_dir_t *dir) { g_assert (sub && dir); g_hash_table_remove (sub_dir_hash, sub); @@ -238,7 +244,7 @@ ip_unmap_all_subs (ip_watched_dir_t *dir) } gboolean -_ip_stop_watching (inotify_sub *sub) +_ip_stop_watching (inotify_sub *sub) { ip_watched_dir_t *dir = NULL; @@ -262,7 +268,8 @@ _ip_stop_watching (inotify_sub *sub) static ip_watched_dir_t * -ip_watched_dir_new (const char *path, gint32 wd) +ip_watched_dir_new (const char *path, + gint32 wd) { ip_watched_dir_t *dir = g_new0 (ip_watched_dir_t, 1); @@ -273,7 +280,7 @@ ip_watched_dir_new (const char *path, gint32 wd) } static void -ip_watched_dir_free (ip_watched_dir_t * dir) +ip_watched_dir_free (ip_watched_dir_t *dir) { g_assert (dir->subs == NULL); g_free (dir->path); @@ -281,7 +288,8 @@ ip_watched_dir_free (ip_watched_dir_t * dir) } static void -ip_wd_delete (gpointer data, gpointer user_data) +ip_wd_delete (gpointer data, + gpointer user_data) { ip_watched_dir_t *dir = data; GList *l = NULL; @@ -299,7 +307,9 @@ ip_wd_delete (gpointer data, gpointer user_data) } static void -ip_event_dispatch (GList *dir_list, GList* pair_dir_list, ik_event_t *event) +ip_event_dispatch (GList *dir_list, + GList *pair_dir_list, + ik_event_t *event) { GList *dirl; diff --git a/gio/inotify/inotify-sub.c b/gio/inotify/inotify-sub.c index f67a563..404dc20 100644 --- a/gio/inotify/inotify-sub.c +++ b/gio/inotify/inotify-sub.c @@ -33,9 +33,9 @@ static gboolean is_debug_enabled = FALSE; #define IS_W if (is_debug_enabled) g_warning static gchar* -dup_dirname(const gchar* dirname) +dup_dirname (const gchar *dirname) { - gchar* d_dirname = g_strdup (dirname); + gchar *d_dirname = g_strdup (dirname); size_t len = strlen (d_dirname); if (d_dirname[len] == '/') @@ -45,9 +45,11 @@ dup_dirname(const gchar* dirname) } inotify_sub* -_ih_sub_new (const gchar* dirname, const gchar* filename, gpointer user_data) +_ih_sub_new (const gchar *dirname, + const gchar *filename, + gpointer user_data) { - inotify_sub* sub = NULL; + inotify_sub *sub = NULL; sub = g_new0 (inotify_sub, 1); sub->dirname = dup_dirname (dirname); @@ -60,7 +62,7 @@ _ih_sub_new (const gchar* dirname, const gchar* filename, gpointer user_data) } void -_ih_sub_free (inotify_sub* sub) +_ih_sub_free (inotify_sub *sub) { g_free (sub->dirname); g_free (sub->filename); -- 2.7.4