[glib] Cosmetic changes
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Cosmetic changes
- Date: Mon, 11 Jun 2012 14:24:43 +0000 (UTC)
commit d4f885478542ad7356b44e2a9965dc1081ea80dc
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jun 11 07:19:42 2012 -0400
Cosmetic changes
tests/gio-test.c | 25 ++++---------------------
tests/iochannel-test.c | 18 +++++++-----------
2 files changed, 11 insertions(+), 32 deletions(-)
---
diff --git a/tests/gio-test.c b/tests/gio-test.c
index cc56ef4..7c28497 100644
--- a/tests/gio-test.c
+++ b/tests/gio-test.c
@@ -82,10 +82,7 @@ read_all (int fd,
if (error != G_IO_ERROR_NONE)
{
- g_print ("gio-test: ...from %d: G_IO_ERROR_%s\n", fd,
- (error == G_IO_ERROR_AGAIN ? "AGAIN" :
- (error == G_IO_ERROR_INVAL ? "INVAL" :
- (error == G_IO_ERROR_UNKNOWN ? "UNKNOWN" : "???"))));
+ g_print ("gio-test: ...from %d: %d\n", fd, error);
if (error == G_IO_ERROR_AGAIN)
continue;
break;
@@ -157,12 +154,7 @@ recv_message (GIOChannel *channel,
for (i = 0; i < nkiddies; i++)
if (seqtab[i].fd == fd)
{
- if (seq != seqtab[i].seq)
- {
- g_print ("gio-test: ...from %d: invalid sequence number %d, expected %d\n",
- fd, seq, seqtab[i].seq);
- g_assert_not_reached ();
- }
+ g_assert_cmpint (seq, ==, seqtab[i].seq);
seqtab[i].seq++;
break;
}
@@ -184,11 +176,7 @@ recv_message (GIOChannel *channel,
g_assert (nb == sizeof (nbytes));
- if (nbytes >= BUFSIZE)
- {
- g_print ("gio-test: ...from %d: nbytes = %d (%#x)!\n", fd, nbytes, nbytes);
- g_assert_not_reached ();
- }
+ g_assert_cmpint (nbytes, <, BUFSIZE);
g_assert (nbytes >= 0 && nbytes < BUFSIZE);
#ifdef VERBOSE
g_print ("gio-test: ...from %d: %d bytes\n", fd, nbytes);
@@ -210,12 +198,7 @@ recv_message (GIOChannel *channel,
}
for (j = 0; j < nbytes; j++)
- if (buf[j] != ' ' + ((nbytes + j) % 95))
- {
- g_print ("gio-test: ...from %d: buf[%d] == '%c', should be '%c'\n",
- fd, j, buf[j], 'a' + ((nbytes + j) % 32));
- g_assert_not_reached ();
- }
+ g_assert (buf[j] == ' ' + ((nbytes + j) % 95));
#ifdef VERBOSE
g_print ("gio-test: ...from %d: OK\n", fd);
#endif
diff --git a/tests/iochannel-test.c b/tests/iochannel-test.c
index 4a67aac..9d6a522 100644
--- a/tests/iochannel-test.c
+++ b/tests/iochannel-test.c
@@ -26,7 +26,7 @@ test_small_writes (void)
g_warning ("Unable to open file %s: %s",
"iochannel-test-outfile",
error->message);
- g_error_free (error);
+ g_clear_error (&error);
exit (1);
}
@@ -75,14 +75,14 @@ gint main (gint argc, gchar * argv[])
if (gerr)
{
g_warning ("Unable to open file %s: %s", filename, gerr->message);
- g_error_free (gerr);
+ g_clear_error (&gerr);
return 1;
}
gio_w = g_io_channel_new_file ("iochannel-test-outfile", "w", &gerr);
if (gerr)
{
g_warning ("Unable to open file %s: %s", "iochannel-test-outfile", gerr->message);
- g_error_free (gerr);
+ g_clear_error (&gerr);
return 1;
}
@@ -93,8 +93,7 @@ gint main (gint argc, gchar * argv[])
/* Keep going if this is just a case of iconv not supporting EUC-JP, see bug 428048 */
if (gerr->code != G_CONVERT_ERROR_NO_CONVERSION)
return 1;
- g_error_free (gerr);
- gerr = NULL;
+ g_clear_error (&gerr);
}
g_io_channel_set_buffer_size (gio_r, BUFFER_SIZE);
@@ -103,8 +102,7 @@ gint main (gint argc, gchar * argv[])
if (status == G_IO_STATUS_ERROR)
{
g_warning ("%s", gerr->message);
- g_error_free (gerr);
- gerr = NULL;
+ g_clear_error (&gerr);
}
buffer = g_string_sized_new (BUFFER_SIZE);
@@ -142,8 +140,7 @@ gint main (gint argc, gchar * argv[])
break;
case G_IO_STATUS_ERROR:
g_warning ("%s", gerr->message);
- g_error_free (gerr);
- gerr = NULL;
+ g_clear_error (&gerr);
break;
default:
g_warning ("Abnormal exit from write loop.");
@@ -157,8 +154,7 @@ gint main (gint argc, gchar * argv[])
if (status == G_IO_STATUS_ERROR)
{
g_warning ("%s", gerr->message);
- g_error_free (gerr);
- gerr = NULL;
+ g_clear_error (&gerr);
}
#ifdef VERBOSE
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]