Jiri 891ef4
From 2e941ae3c1d13968bda8bb4594a5aa566aa2e5dd Mon Sep 17 00:00:00 2001
Jiri 891ef4
From: Jiri Moskovcak <jmoskovc@redhat.com>
Jiri 891ef4
Date: Wed, 7 Dec 2011 16:12:28 +0100
Jiri 891ef4
Subject: [PATCH 5/5] more glib2.31 fixes
Jiri 891ef4
Jiri 891ef4
---
Jiri 891ef4
 src/daemon/abrtd.c |   17 +++++++++++++----
Jiri 891ef4
 1 files changed, 13 insertions(+), 4 deletions(-)
Jiri 891ef4
Jiri 891ef4
diff --git a/src/daemon/abrtd.c b/src/daemon/abrtd.c
Jiri 891ef4
index d3a759a..3d71e80 100644
Jiri 891ef4
--- a/src/daemon/abrtd.c
Jiri 891ef4
+++ b/src/daemon/abrtd.c
Jiri 891ef4
@@ -238,7 +238,7 @@ static gboolean handle_signal_cb(GIOChannel *gio, GIOCondition condition, gpoint
Jiri 891ef4
 {
Jiri 891ef4
     uint8_t signo;
Jiri 891ef4
     gsize len = 0;
Jiri 891ef4
-    g_io_channel_read(gio, (void*) &signo, 1, &len;;
Jiri 891ef4
+    g_io_channel_read_chars(gio, (void*) &signo, 1, &len, NULL);
Jiri 891ef4
     if (len == 1)
Jiri 891ef4
     {
Jiri 891ef4
         /* we did receive a signal */
Jiri 891ef4
@@ -382,10 +382,19 @@ static gboolean handle_inotify_cb(GIOChannel *gio, GIOCondition condition, gpoin
Jiri 891ef4
     char *buf = (char*)xmalloc(inotify_bytes);
Jiri 891ef4
     errno = 0;
Jiri 891ef4
     gsize len;
Jiri 891ef4
-    GIOError err = g_io_channel_read(gio, buf, inotify_bytes, &len;;
Jiri 891ef4
-    if (err != G_IO_ERROR_NONE)
Jiri 891ef4
+    GError *gerror = NULL;
Jiri 891ef4
+    g_io_channel_set_encoding(gio, NULL, &gerror);
Jiri 891ef4
+    /* need to set the encoding otherwise we get:
Jiri 891ef4
+     * Invalid byte sequence in conversion input
Jiri 891ef4
+     * according to manual "NULL" is safe for binary data
Jiri 891ef4
+    */
Jiri 891ef4
+    if (gerror)
Jiri 891ef4
+        perror_msg("Can't set encoding on gio channel: '%s'", gerror->message);
Jiri 891ef4
+
Jiri 891ef4
+    GIOStatus err = g_io_channel_read_chars(gio, buf, inotify_bytes, &len, &gerror);
Jiri 891ef4
+    if (err != G_IO_STATUS_NORMAL)
Jiri 891ef4
     {
Jiri 891ef4
-        perror_msg("Error reading inotify fd");
Jiri 891ef4
+        perror_msg("Error reading inotify fd: %s", gerror ? gerror->message : "unknown");
Jiri 891ef4
         free(buf);
Jiri 891ef4
         return FALSE; /* "remove this event" (huh??) */
Jiri 891ef4
     }
Jiri 891ef4
-- 
Jiri 891ef4
1.7.7.3
Jiri 891ef4