From 685e7910b965a703042ea48adb7dcad02b91d9e6 Mon Sep 17 00:00:00 2001 From: Eric Koegel Date: Tue, 11 Feb 2014 16:35:12 +0300 Subject: [PATCH] Clean up some compiler warnings and deprecated functions --- src/ck-event-logger.c | 12 +++++++++--- src/ck-file-monitor-inotify.c | 3 --- src/ck-manager.c | 18 ++++++++++++++---- src/ck-seat.c | 3 --- src/ck-session-leader.c | 11 ----------- src/ck-session.c | 3 --- src/ck-tty-idle-monitor.c | 3 +-- src/ck-vt-monitor.c | 4 ++++ src/main.c | 13 ++++++++++++- src/test-event-logger.c | 5 +++++ src/test-tty-idle-monitor.c | 2 ++ src/test-vt-monitor.c | 5 +++++ tools/ck-log-system-restart.c | 5 ++++- tools/ck-log-system-start.c | 5 ++++- tools/ck-log-system-stop.c | 5 ++++- tools/list-sessions.c | 2 ++ tools/udev-acl.c | 3 --- 17 files changed, 66 insertions(+), 36 deletions(-) diff --git a/src/ck-event-logger.c b/src/ck-event-logger.c index 8871177..6c82576 100644 --- a/src/ck-event-logger.c +++ b/src/ck-event-logger.c @@ -282,6 +282,13 @@ create_writer_thread (CkEventLogger *event_logger) g_debug ("Creating thread for log writing"); error = NULL; + +#if GLIB_CHECK_VERSION(2, 32, 0) + event_logger->priv->writer_thread = g_thread_try_new ("writer_thread_start", + (GThreadFunc)writer_thread_start, + event_logger, + &error); +#else event_logger->priv->writer_thread = g_thread_create_full ((GThreadFunc)writer_thread_start, event_logger, 65536, @@ -289,6 +296,8 @@ create_writer_thread (CkEventLogger *event_logger) TRUE, G_THREAD_PRIORITY_NORMAL, &error); +#endif + if (event_logger->priv->writer_thread == NULL) { g_debug ("Unable to create thread: %s", error->message); g_error_free (error); @@ -317,9 +326,6 @@ ck_event_logger_constructor (GType type, GObjectConstructParam *construct_properties) { CkEventLogger *event_logger; - CkEventLoggerClass *klass; - - klass = CK_EVENT_LOGGER_CLASS (g_type_class_peek (CK_TYPE_EVENT_LOGGER)); event_logger = CK_EVENT_LOGGER (G_OBJECT_CLASS (ck_event_logger_parent_class)->constructor (type, n_construct_properties, diff --git a/src/ck-file-monitor-inotify.c b/src/ck-file-monitor-inotify.c index c4a11bd..b734f55 100644 --- a/src/ck-file-monitor-inotify.c +++ b/src/ck-file-monitor-inotify.c @@ -427,11 +427,8 @@ handle_inotify_event (CkFileMonitor *monitor, { CkFileMonitorEvent event; const char *path; - char *freeme; char *mask_str; - freeme = NULL; - if (ievent->len > 0) { path = ievent->name; } else { diff --git a/src/ck-manager.c b/src/ck-manager.c index a040be3..985e55e 100644 --- a/src/ck-manager.c +++ b/src/ck-manager.c @@ -2396,9 +2396,9 @@ remove_sessions_for_connection (CkManager *manager, g_debug ("Removing sessions for service name: %s", service_name); - n_removed = g_hash_table_foreach_remove (manager->priv->leaders, - (GHRFunc)remove_leader_for_connection, - &data); + g_hash_table_foreach_remove (manager->priv->leaders, + (GHRFunc)remove_leader_for_connection, + &data); } @@ -2417,13 +2417,23 @@ bus_name_owner_changed (DBusGProxy *bus_proxy, service_name, old_service_name, new_service_name); } +static void +polkit_authority_get_cb (GObject *source_object, + GAsyncResult *res, + gpointer user_data) +{ + CkManager *manager = CK_MANAGER (user_data); + + manager->priv->pol_ctx = polkit_authority_get_finish (res, NULL); +} + static gboolean register_manager (CkManager *manager) { GError *error = NULL; #ifdef HAVE_POLKIT - manager->priv->pol_ctx = polkit_authority_get (); + polkit_authority_get_async (NULL, polkit_authority_get_cb, manager); #endif error = NULL; diff --git a/src/ck-seat.c b/src/ck-seat.c index 59db29f..6e6800f 100644 --- a/src/ck-seat.c +++ b/src/ck-seat.c @@ -910,9 +910,6 @@ ck_seat_constructor (GType type, GObjectConstructParam *construct_properties) { CkSeat *seat; - CkSeatClass *klass; - - klass = CK_SEAT_CLASS (g_type_class_peek (CK_TYPE_SEAT)); seat = CK_SEAT (G_OBJECT_CLASS (ck_seat_parent_class)->constructor (type, n_construct_properties, diff --git a/src/ck-session-leader.c b/src/ck-session-leader.c index c2ab15b..b94f481 100644 --- a/src/ck-session-leader.c +++ b/src/ck-session-leader.c @@ -568,10 +568,6 @@ ck_session_leader_set_property (GObject *object, const GValue *value, GParamSpec *pspec) { - CkSessionLeader *self; - - self = CK_SESSION_LEADER (object); - switch (prop_id) { default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -585,10 +581,6 @@ ck_session_leader_get_property (GObject *object, GValue *value, GParamSpec *pspec) { - CkSessionLeader *self; - - self = CK_SESSION_LEADER (object); - switch (prop_id) { default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -602,9 +594,6 @@ ck_session_leader_constructor (GType type, GObjectConstructParam *construct_properties) { CkSessionLeader *session_leader; - CkSessionLeaderClass *klass; - - klass = CK_SESSION_LEADER_CLASS (g_type_class_peek (CK_TYPE_SESSION_LEADER)); session_leader = CK_SESSION_LEADER (G_OBJECT_CLASS (ck_session_leader_parent_class)->constructor (type, n_construct_properties, diff --git a/src/ck-session.c b/src/ck-session.c index f291bf3..f84a73b 100644 --- a/src/ck-session.c +++ b/src/ck-session.c @@ -896,9 +896,6 @@ ck_session_constructor (GType type, GObjectConstructParam *construct_properties) { CkSession *session; - CkSessionClass *klass; - - klass = CK_SESSION_CLASS (g_type_class_peek (CK_TYPE_SESSION)); session = CK_SESSION (G_OBJECT_CLASS (ck_session_parent_class)->constructor (type, n_construct_properties, diff --git a/src/ck-tty-idle-monitor.c b/src/ck-tty-idle-monitor.c index eb071e2..4e9ecdc 100644 --- a/src/ck-tty-idle-monitor.c +++ b/src/ck-tty-idle-monitor.c @@ -220,7 +220,6 @@ check_tty_idle (CkTtyIdleMonitor *monitor) { struct stat sb; gboolean is_idle; - gboolean changed; time_t now; time_t idletime; time_t last_access; @@ -244,7 +243,7 @@ check_tty_idle (CkTtyIdleMonitor *monitor) idletime = now - last_access; is_idle = (idletime >= monitor->priv->threshold); - changed = tty_idle_monitor_set_idle_hint_internal (monitor, is_idle); + tty_idle_monitor_set_idle_hint_internal (monitor, is_idle); monitor->priv->timeout_id = 0; diff --git a/src/ck-vt-monitor.c b/src/ck-vt-monitor.c index cf44983..362e31b 100644 --- a/src/ck-vt-monitor.c +++ b/src/ck-vt-monitor.c @@ -364,7 +364,11 @@ vt_add_watch_unlocked (CkVtMonitor *vt_monitor, id = GINT_TO_POINTER (num); error = NULL; +#if GLIB_CHECK_VERSION(2, 32, 0) + thread = g_thread_try_new ("vt_thread_start", (GThreadFunc)vt_thread_start, data, &error); +#else thread = g_thread_create_full ((GThreadFunc)vt_thread_start, data, 65536, FALSE, TRUE, G_THREAD_PRIORITY_NORMAL, &error); +#endif if (thread == NULL) { g_debug ("Unable to create thread: %s", error->message); g_error_free (error); diff --git a/src/main.c b/src/main.c index a39bd71..583f4e9 100644 --- a/src/main.c +++ b/src/main.c @@ -227,8 +227,13 @@ create_pid_file (void) if ((pf = open (CONSOLE_KIT_PID_FILE, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0644)) > 0) { snprintf (pid, sizeof (pid), "%lu\n", (long unsigned) getpid ()); written = write (pf, pid, strlen (pid)); - close (pf); + if (written != strlen(pid)) { + g_warning ("unable to write pid file %s: %s", + CONSOLE_KIT_PID_FILE, + g_strerror (errno)); + } g_atexit (delete_pid); + close (pf); } else { g_warning ("Unable to write pid file %s: %s", CONSOLE_KIT_PID_FILE, @@ -260,11 +265,17 @@ main (int argc, ret = 1; +#if !GLIB_CHECK_VERSION(2, 32, 0) if (! g_thread_supported ()) { g_thread_init (NULL); } +#endif + dbus_g_thread_init (); + +#if !GLIB_CHECK_VERSION(2, 36, 0) g_type_init (); +#endif if (! ck_is_root_user ()) { g_warning ("Must be run as root"); diff --git a/src/test-event-logger.c b/src/test-event-logger.c index e3d7db0..129651b 100644 --- a/src/test-event-logger.c +++ b/src/test-event-logger.c @@ -69,10 +69,15 @@ main (int argc, char **argv) CkEventLogger *logger; char *filename; +#if !GLIB_CHECK_VERSION(2, 32, 0) if (! g_thread_supported ()) { g_thread_init (NULL); } +#endif + +#if !GLIB_CHECK_VERSION(2, 36, 0) g_type_init (); +#endif filename = g_build_filename (g_get_tmp_dir (), "ck-logger-test.log", NULL); diff --git a/src/test-tty-idle-monitor.c b/src/test-tty-idle-monitor.c index f56b37f..c3adea1 100644 --- a/src/test-tty-idle-monitor.c +++ b/src/test-tty-idle-monitor.c @@ -73,7 +73,9 @@ main (int argc, char **argv) CkTtyIdleMonitor *monitor; char *device; +#if !GLIB_CHECK_VERSION(2, 36, 0) g_type_init (); +#endif if (argc < 2) { device = ttyname (0); diff --git a/src/test-vt-monitor.c b/src/test-vt-monitor.c index c445865..afcacc2 100644 --- a/src/test-vt-monitor.c +++ b/src/test-vt-monitor.c @@ -56,10 +56,15 @@ main (int argc, char **argv) guint num; gboolean res; +#if !GLIB_CHECK_VERSION(2, 32, 0) if (! g_thread_supported ()) { g_thread_init (NULL); } +#endif + +#if !GLIB_CHECK_VERSION(2, 36, 0) g_type_init (); +#endif if (! ck_is_root_user ()) { g_warning ("Must be run as root"); diff --git a/tools/ck-log-system-restart.c b/tools/ck-log-system-restart.c index e53670f..0b022f2 100644 --- a/tools/ck-log-system-restart.c +++ b/tools/ck-log-system-restart.c @@ -98,7 +98,10 @@ retry: goto out; } - fchown (fd, 0, 0); + if (fchown (fd, 0, 0) == -1) { + g_warning ("Error changing owner of log file (%s)", + g_strerror (errno)); + } file = fdopen (fd, "a"); if (file == NULL) { diff --git a/tools/ck-log-system-start.c b/tools/ck-log-system-start.c index 0860429..b4a29b5 100644 --- a/tools/ck-log-system-start.c +++ b/tools/ck-log-system-start.c @@ -100,7 +100,10 @@ retry: goto out; } - fchown (fd, 0, 0); + if (fchown (fd, 0, 0) == -1) { + g_warning ("Error changing owner of log file (%s)", + g_strerror (errno)); + } file = fdopen (fd, "a"); if (file == NULL) { diff --git a/tools/ck-log-system-stop.c b/tools/ck-log-system-stop.c index a59a1e9..879402b 100644 --- a/tools/ck-log-system-stop.c +++ b/tools/ck-log-system-stop.c @@ -98,7 +98,10 @@ retry: goto out; } - fchown (fd, 0, 0); + if (fchown (fd, 0, 0) == -1) { + g_warning ("Error changing owner of log file (%s)", + g_strerror (errno)); + } file = fdopen (fd, "a"); if (file == NULL) { diff --git a/tools/list-sessions.c b/tools/list-sessions.c index c3a020b..d7d004d 100644 --- a/tools/list-sessions.c +++ b/tools/list-sessions.c @@ -373,7 +373,9 @@ main (int argc, { NULL } }; +#if !GLIB_CHECK_VERSION(2, 36, 0) g_type_init (); +#endif context = g_option_context_new (NULL); g_option_context_add_main_entries (context, entries, NULL); diff --git a/tools/udev-acl.c b/tools/udev-acl.c index 628cfbe..7080bc5 100644 --- a/tools/udev-acl.c +++ b/tools/udev-acl.c @@ -332,9 +332,6 @@ int main (int argc, char* argv[]) const char* remove_session_id = NULL; int rc = 0; - /* valgrind is more important to us than a slice allocator */ - g_slice_set_config (G_SLICE_CONFIG_ALWAYS_MALLOC, 1); - while (1) { int option; -- 1.8.5.4