mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-12 21:50:36 +01:00
Coding style fixes
svn path=/trunk/; revision=6337
This commit is contained in:
parent
d16037e0e7
commit
a043325ec1
@ -1,3 +1,9 @@
|
||||
2008-01-20 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* 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 <mclasen@redhat.com>
|
||||
|
||||
* gfile.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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user