fix warnings from gcc compilation with my mad CFLAGS

This commit is contained in:
Benjamin Otte
2009-06-29 18:24:08 +02:00
parent 4b8ad50fc4
commit afd63c3281
12 changed files with 119 additions and 106 deletions

View File

@@ -173,14 +173,14 @@ enum TestDataType {
TEST_DATA_UINT64 TEST_DATA_UINT64
}; };
#define TEST_DATA_RETYPE_BUFF(a, v) \ #define TEST_DATA_RETYPE_BUFF(a, t, v) \
(a == TEST_DATA_BYTE ? *(guchar*)v : \ (a == TEST_DATA_BYTE ? (t) *(guchar*)v : \
(a == TEST_DATA_INT16 ? *(gint16*)v : \ (a == TEST_DATA_INT16 ? (t) *(gint16*)v : \
(a == TEST_DATA_UINT16 ? *(guint16*)v : \ (a == TEST_DATA_UINT16 ? (t) *(guint16*)v : \
(a == TEST_DATA_INT32 ? *(gint32*)v : \ (a == TEST_DATA_INT32 ? (t) *(gint32*)v : \
(a == TEST_DATA_UINT32 ? *(guint32*)v : \ (a == TEST_DATA_UINT32 ? (t) *(guint32*)v : \
(a == TEST_DATA_INT64 ? *(gint64*)v : \ (a == TEST_DATA_INT64 ? (t) *(gint64*)v : \
*(guint64*)v )))))) (t) *(guint64*)v ))))))
static void static void
@@ -216,6 +216,9 @@ test_data_array (GInputStream *stream, GInputStream *base_stream,
case TEST_DATA_UINT64: case TEST_DATA_UINT64:
data_size = 8; data_size = 8;
break; break;
default:
g_assert_not_reached ();
break;
} }
/* Set flag to swap bytes if needed */ /* Set flag to swap bytes if needed */
@@ -260,9 +263,12 @@ test_data_array (GInputStream *stream, GInputStream *base_stream,
if (swap) if (swap)
data = (guint64)GUINT64_SWAP_LE_BE((guint64)data); data = (guint64)GUINT64_SWAP_LE_BE((guint64)data);
break; break;
default:
g_assert_not_reached ();
break;
} }
if ((data) && (! error)) if ((data) && (! error))
g_assert_cmpint (data, ==, TEST_DATA_RETYPE_BUFF(data_type, ((guchar*)buffer + pos))); g_assert_cmpint (data, ==, TEST_DATA_RETYPE_BUFF(data_type, gint64, ((guchar*)buffer + pos)));
pos += data_size; pos += data_size;
} }
@@ -276,11 +282,11 @@ test_read_int (void)
{ {
GInputStream *stream; GInputStream *stream;
GInputStream *base_stream; GInputStream *base_stream;
GRand *rand; GRand *randomizer;
int i; int i;
gpointer buffer; gpointer buffer;
rand = g_rand_new (); randomizer = g_rand_new ();
buffer = g_malloc0 (MAX_BYTES); buffer = g_malloc0 (MAX_BYTES);
/* Fill in some random data */ /* Fill in some random data */
@@ -288,7 +294,7 @@ test_read_int (void)
{ {
guchar x = 0; guchar x = 0;
while (! x) while (! x)
x = (guchar)g_rand_int (rand); x = (guchar)g_rand_int (randomizer);
*(guchar*)((guchar*)buffer + sizeof(guchar) * i) = x; *(guchar*)((guchar*)buffer + sizeof(guchar) * i) = x;
} }
@@ -308,7 +314,7 @@ test_read_int (void)
g_object_unref (base_stream); g_object_unref (base_stream);
g_object_unref (stream); g_object_unref (stream);
g_rand_free (rand); g_rand_free (randomizer);
g_free (buffer); g_free (buffer);
} }

View File

@@ -109,23 +109,14 @@ enum TestDataType {
TEST_DATA_UINT64 TEST_DATA_UINT64
}; };
#define TEST_DATA_RETYPE(a, v) \ #define TEST_DATA_RETYPE_BUFF(a, t, v) \
(a == TEST_DATA_BYTE ? (guchar)v : \ (a == TEST_DATA_BYTE ? (t) *(guchar*)v : \
(a == TEST_DATA_INT16 ? (gint16)v : \ (a == TEST_DATA_INT16 ? (t) *(gint16*)v : \
(a == TEST_DATA_UINT16 ? (guint16)v : \ (a == TEST_DATA_UINT16 ? (t) *(guint16*)v : \
(a == TEST_DATA_INT32 ? (gint32)v : \ (a == TEST_DATA_INT32 ? (t) *(gint32*)v : \
(a == TEST_DATA_UINT32 ? (guint32)v : \ (a == TEST_DATA_UINT32 ? (t) *(guint32*)v : \
(a == TEST_DATA_INT64 ? (gint64)v : \ (a == TEST_DATA_INT64 ? (t) *(gint64*)v : \
(guint64)v )))))) (t) *(guint64*)v ))))))
#define TEST_DATA_RETYPE_BUFF(a, v) \
(a == TEST_DATA_BYTE ? *(guchar*)v : \
(a == TEST_DATA_INT16 ? *(gint16*)v : \
(a == TEST_DATA_UINT16 ? *(guint16*)v : \
(a == TEST_DATA_INT32 ? *(gint32*)v : \
(a == TEST_DATA_UINT32 ? *(guint32*)v : \
(a == TEST_DATA_INT64 ? *(gint64*)v : \
*(guint64*)v ))))))
@@ -171,6 +162,9 @@ test_data_array (gpointer buffer, int len,
case TEST_DATA_UINT64: case TEST_DATA_UINT64:
data_size = 8; data_size = 8;
break; break;
default:
g_assert_not_reached ();
break;
} }
/* Set flag to swap bytes if needed */ /* Set flag to swap bytes if needed */
@@ -184,25 +178,28 @@ test_data_array (gpointer buffer, int len,
switch (data_type) switch (data_type)
{ {
case TEST_DATA_BYTE: case TEST_DATA_BYTE:
res = g_data_output_stream_put_byte (G_DATA_OUTPUT_STREAM (stream), TEST_DATA_RETYPE_BUFF (data_type, ((guchar*)buffer + pos)), NULL, &error); res = g_data_output_stream_put_byte (G_DATA_OUTPUT_STREAM (stream), TEST_DATA_RETYPE_BUFF (data_type, guchar, ((guchar*)buffer + pos)), NULL, &error);
break; break;
case TEST_DATA_INT16: case TEST_DATA_INT16:
res = g_data_output_stream_put_int16 (G_DATA_OUTPUT_STREAM (stream), TEST_DATA_RETYPE_BUFF (data_type, ((guchar*)buffer + pos)), NULL, &error); res = g_data_output_stream_put_int16 (G_DATA_OUTPUT_STREAM (stream), TEST_DATA_RETYPE_BUFF (data_type, gint16, ((guchar*)buffer + pos)), NULL, &error);
break; break;
case TEST_DATA_UINT16: case TEST_DATA_UINT16:
res = g_data_output_stream_put_uint16 (G_DATA_OUTPUT_STREAM (stream), TEST_DATA_RETYPE_BUFF (data_type, ((guchar*)buffer + pos)), NULL, &error); res = g_data_output_stream_put_uint16 (G_DATA_OUTPUT_STREAM (stream), TEST_DATA_RETYPE_BUFF (data_type, guint16, ((guchar*)buffer + pos)), NULL, &error);
break; break;
case TEST_DATA_INT32: case TEST_DATA_INT32:
res = g_data_output_stream_put_int32 (G_DATA_OUTPUT_STREAM (stream), TEST_DATA_RETYPE_BUFF (data_type, ((guchar*)buffer + pos)), NULL, &error); res = g_data_output_stream_put_int32 (G_DATA_OUTPUT_STREAM (stream), TEST_DATA_RETYPE_BUFF (data_type, gint32, ((guchar*)buffer + pos)), NULL, &error);
break; break;
case TEST_DATA_UINT32: case TEST_DATA_UINT32:
res = g_data_output_stream_put_uint32 (G_DATA_OUTPUT_STREAM (stream), TEST_DATA_RETYPE_BUFF (data_type, ((guchar*)buffer + pos)), NULL, &error); res = g_data_output_stream_put_uint32 (G_DATA_OUTPUT_STREAM (stream), TEST_DATA_RETYPE_BUFF (data_type, guint32, ((guchar*)buffer + pos)), NULL, &error);
break; break;
case TEST_DATA_INT64: case TEST_DATA_INT64:
res = g_data_output_stream_put_int64 (G_DATA_OUTPUT_STREAM (stream), TEST_DATA_RETYPE_BUFF (data_type, ((guchar*)buffer + pos)), NULL, &error); res = g_data_output_stream_put_int64 (G_DATA_OUTPUT_STREAM (stream), TEST_DATA_RETYPE_BUFF (data_type, gint64, ((guchar*)buffer + pos)), NULL, &error);
break; break;
case TEST_DATA_UINT64: case TEST_DATA_UINT64:
res = g_data_output_stream_put_uint64 (G_DATA_OUTPUT_STREAM (stream), TEST_DATA_RETYPE_BUFF (data_type, ((guchar*)buffer + pos)), NULL, &error); res = g_data_output_stream_put_uint64 (G_DATA_OUTPUT_STREAM (stream), TEST_DATA_RETYPE_BUFF (data_type, guint64, ((guchar*)buffer + pos)), NULL, &error);
break;
default:
g_assert_not_reached ();
break; break;
} }
g_assert_no_error (error); g_assert_no_error (error);
@@ -216,7 +213,7 @@ test_data_array (gpointer buffer, int len,
data = 0; data = 0;
while (pos < len) while (pos < len)
{ {
data = TEST_DATA_RETYPE_BUFF(data_type, ((guchar*)stream_data + pos)); data = TEST_DATA_RETYPE_BUFF(data_type, guint64, ((guchar*)stream_data + pos));
if (swap) if (swap)
{ {
switch (data_type) switch (data_type)
@@ -225,19 +222,22 @@ test_data_array (gpointer buffer, int len,
break; break;
case TEST_DATA_UINT16: case TEST_DATA_UINT16:
case TEST_DATA_INT16: case TEST_DATA_INT16:
data = TEST_DATA_RETYPE(data_type, GUINT16_SWAP_LE_BE(TEST_DATA_RETYPE(data_type, data))); data = GUINT16_SWAP_LE_BE((guint16) data);
break; break;
case TEST_DATA_UINT32: case TEST_DATA_UINT32:
case TEST_DATA_INT32: case TEST_DATA_INT32:
data = TEST_DATA_RETYPE(data_type, GUINT32_SWAP_LE_BE(TEST_DATA_RETYPE(data_type, data))); data = GUINT32_SWAP_LE_BE((guint32) data);
break; break;
case TEST_DATA_UINT64: case TEST_DATA_UINT64:
case TEST_DATA_INT64: case TEST_DATA_INT64:
data = TEST_DATA_RETYPE(data_type, GUINT64_SWAP_LE_BE(TEST_DATA_RETYPE(data_type, data))); data = GUINT64_SWAP_LE_BE((guint64) data);
break;
default:
g_assert_not_reached ();
break; break;
} }
} }
g_assert_cmpint (data, ==, TEST_DATA_RETYPE_BUFF(data_type, ((guchar*)buffer + pos))); g_assert_cmpint (data, ==, TEST_DATA_RETYPE_BUFF(data_type, guint64, ((guchar*)buffer + pos)));
break; break;
pos += data_size; pos += data_size;
@@ -251,18 +251,18 @@ test_data_array (gpointer buffer, int len,
static void static void
test_read_int (void) test_read_int (void)
{ {
GRand *rand; GRand *randomizer;
gpointer buffer; gpointer buffer;
int i; int i;
rand = g_rand_new (); randomizer = g_rand_new ();
buffer = g_malloc0(MAX_BYTES_BINARY); buffer = g_malloc0(MAX_BYTES_BINARY);
/* Fill in some random data */ /* Fill in some random data */
for (i = 0; i < MAX_BYTES_BINARY; i++) for (i = 0; i < MAX_BYTES_BINARY; i++)
{ {
guchar x = 0; guchar x = 0;
while (! x) x = (guchar)g_rand_int (rand); while (! x) x = (guchar)g_rand_int (randomizer);
*(guchar*)((guchar*)buffer + sizeof (guchar) * i) = x; *(guchar*)((guchar*)buffer + sizeof (guchar) * i) = x;
} }
@@ -273,7 +273,7 @@ test_read_int (void)
test_data_array (buffer, MAX_BYTES_BINARY, j, i); test_data_array (buffer, MAX_BYTES_BINARY, j, i);
} }
g_rand_free (rand); g_rand_free (randomizer);
g_free (buffer); g_free (buffer);
} }

View File

@@ -222,11 +222,11 @@ cleanup_dir_recurse (GFile *parent, GFile *root)
} }
static void static void
cleanup_subdirs (const char *basedir) cleanup_subdirs (const char *base_dir)
{ {
GFile *base, *file; GFile *base, *file;
base = g_file_new_for_path (basedir); base = g_file_new_for_path (base_dir);
file = g_file_get_child (base, "applications"); file = g_file_get_child (base, "applications");
cleanup_dir_recurse (file, file); cleanup_dir_recurse (file, file);
g_object_unref (file); g_object_unref (file);

View File

@@ -128,7 +128,7 @@ test_g_file_new_for_path (void)
{"/UTF-8 p\xc5\x99\xc3\xadli\xc5\xa1 \xc5\xbelu\xc5\xa5ou\xc4\x8dk\xc3\xbd k\xc5\xaf\xc5\x88", TRUE, 0, "/UTF-8 p\xc5\x99\xc3\xadli\xc5\xa1 \xc5\xbelu\xc5\xa5ou\xc4\x8dk\xc3\xbd k\xc5\xaf\xc5\x88/"} {"/UTF-8 p\xc5\x99\xc3\xadli\xc5\xa1 \xc5\xbelu\xc5\xa5ou\xc4\x8dk\xc3\xbd k\xc5\xaf\xc5\x88", TRUE, 0, "/UTF-8 p\xc5\x99\xc3\xadli\xc5\xa1 \xc5\xbelu\xc5\xa5ou\xc4\x8dk\xc3\xbd k\xc5\xaf\xc5\x88/"}
}; };
int i; guint i;
for (i = 0; i < G_N_ELEMENTS (cmp_paths); i++) for (i = 0; i < G_N_ELEMENTS (cmp_paths); i++)
{ {
gboolean equal = compare_two_files (FALSE, cmp_paths[i].path1, cmp_paths[i].path2); gboolean equal = compare_two_files (FALSE, cmp_paths[i].path1, cmp_paths[i].path2);
@@ -157,7 +157,7 @@ test_g_file_new_for_uri (void)
{"file:///UTF-8%20p%C5%99%C3%ADli%C5%A1%20%C5%BElu%C5%A5ou%C4%8Dk%C3%BD%20k%C5%AF%C5%88", TRUE, 0, "file:///UTF-8%20p%C5%99%C3%ADli%C5%A1%20%C5%BElu%C5%A5ou%C4%8Dk%C3%BD%20k%C5%AF%C5%88/"} {"file:///UTF-8%20p%C5%99%C3%ADli%C5%A1%20%C5%BElu%C5%A5ou%C4%8Dk%C3%BD%20k%C5%AF%C5%88", TRUE, 0, "file:///UTF-8%20p%C5%99%C3%ADli%C5%A1%20%C5%BElu%C5%A5ou%C4%8Dk%C3%BD%20k%C5%AF%C5%88/"}
}; };
int i; guint i;
for (i = 0; i < G_N_ELEMENTS (cmp_uris); i++) for (i = 0; i < G_N_ELEMENTS (cmp_uris); i++)
{ {
gboolean equal = compare_two_files (TRUE, cmp_uris[i].path1, cmp_uris[i].path2); gboolean equal = compare_two_files (TRUE, cmp_uris[i].path1, cmp_uris[i].path2);
@@ -205,7 +205,7 @@ test_g_file_dup (void)
{"file:///UTF-8%20p%C5%99%C3%ADli%C5%A1%20%C5%BElu%C5%A5ou%C4%8Dk%C3%BD%20k%C5%AF%C5%88", 0, TRUE, ""}, {"file:///UTF-8%20p%C5%99%C3%ADli%C5%A1%20%C5%BElu%C5%A5ou%C4%8Dk%C3%BD%20k%C5%AF%C5%88", 0, TRUE, ""},
}; };
int i; guint i;
for (i = 0; i < G_N_ELEMENTS (dup_paths); i++) for (i = 0; i < G_N_ELEMENTS (dup_paths); i++)
{ {
gboolean equal = dup_equals (dup_paths[i].use_uri, dup_paths[i].path1); gboolean equal = dup_equals (dup_paths[i].use_uri, dup_paths[i].path1);
@@ -268,7 +268,7 @@ test_g_file_get_parse_name_utf8 (void)
{"file:///invalid%08/UTF-8%20p%C5%99%C3%ADli%C5%A1%20%C5%BElu%C5%A5ou%C4%8Dk%C3%BD%20k%C5%AF%C5%88/", 0, TRUE, "file:///invalid%08/UTF-8%20p\xc5\x99\xc3\xadli\xc5\xa1%20\xc5\xbelu\xc5\xa5ou\xc4\x8dk\xc3\xbd%20k\xc5\xaf\xc5\x88"}, {"file:///invalid%08/UTF-8%20p%C5%99%C3%ADli%C5%A1%20%C5%BElu%C5%A5ou%C4%8Dk%C3%BD%20k%C5%AF%C5%88/", 0, TRUE, "file:///invalid%08/UTF-8%20p\xc5\x99\xc3\xadli\xc5\xa1%20\xc5\xbelu\xc5\xa5ou\xc4\x8dk\xc3\xbd%20k\xc5\xaf\xc5\x88"},
}; };
int i; guint i;
for (i = 0; i < G_N_ELEMENTS (strings); i++) for (i = 0; i < G_N_ELEMENTS (strings); i++)
{ {
gboolean equal = parse_check_utf8 (strings[i].use_uri, strings[i].path1, strings[i].path2); gboolean equal = parse_check_utf8 (strings[i].use_uri, strings[i].path1, strings[i].path2);
@@ -328,7 +328,7 @@ test_g_file_new_for_commandline_arg (void)
GFile *file; GFile *file;
char *resolved; char *resolved;
char *cwd; char *cwd;
int i; guint i;
for (i = 0; i < G_N_ELEMENTS (arg_data); i++) for (i = 0; i < G_N_ELEMENTS (arg_data); i++)
{ {
@@ -422,7 +422,7 @@ test_g_file_has_prefix (void)
#endif #endif
}; };
int i; guint i;
for (i = 0; i < G_N_ELEMENTS (dirs); i++) for (i = 0; i < G_N_ELEMENTS (dirs); i++)
{ {
char *s = get_relative_path (dirs[i].use_uri, dirs[i].equal, dirs[i].path1, dirs[i].path2); char *s = get_relative_path (dirs[i].use_uri, dirs[i].equal, dirs[i].path1, dirs[i].path2);
@@ -437,7 +437,7 @@ roundtrip_parent_child (const gboolean use_uri, const gboolean under_root_descen
const char *path, const char *dir_holder) const char *path, const char *dir_holder)
{ {
GFile *files[6] = {NULL}; GFile *files[6] = {NULL};
int i; guint i;
if (use_uri) if (use_uri)
{ {
@@ -497,7 +497,7 @@ test_g_file_get_parent_child (void)
{"dav://www.gtk.org/plan/meetings", FALSE, TRUE, "meetings"}, {"dav://www.gtk.org/plan/meetings", FALSE, TRUE, "meetings"},
}; };
int i; guint i;
for (i = 0; i < G_N_ELEMENTS (paths); i++) for (i = 0; i < G_N_ELEMENTS (paths); i++)
roundtrip_parent_child (paths[i].use_uri, paths[i].equal, paths[i].path1, paths[i].path2); roundtrip_parent_child (paths[i].use_uri, paths[i].equal, paths[i].path1, paths[i].path2);
} }

View File

@@ -12,7 +12,7 @@ static GOptionEntry cmd_entries[] = {
static void static void
send_error (GOutputStream *out, send_error (GOutputStream *out,
int error_code, int error_code,
char *reason) const char *reason)
{ {
char *res; char *res;

View File

@@ -181,7 +181,7 @@ test_create_structure (gconstpointer test_data)
GError *error; GError *error;
GFileOutputStream *outs; GFileOutputStream *outs;
GDataOutputStream *outds; GDataOutputStream *outds;
int i; guint i;
struct StructureItem item; struct StructureItem item;
g_assert (test_data != NULL); g_assert (test_data != NULL);
@@ -220,6 +220,10 @@ test_create_structure (gconstpointer test_data)
item.link_to); item.link_to);
child = create_symlink (root, item.filename, item.link_to); child = create_symlink (root, item.filename, item.link_to);
break; break;
case G_FILE_TYPE_UNKNOWN:
case G_FILE_TYPE_SPECIAL:
case G_FILE_TYPE_SHORTCUT:
case G_FILE_TYPE_MOUNTABLE:
default: default:
break; break;
} }
@@ -385,7 +389,7 @@ test_initial_structure (gconstpointer test_data)
gboolean res; gboolean res;
GError *error; GError *error;
GFileInputStream *ins; GFileInputStream *ins;
int i; guint i;
GFileInfo *info; GFileInfo *info;
guint32 size; guint32 size;
guchar *buffer; guchar *buffer;
@@ -486,7 +490,7 @@ traverse_recurse_dirs (GFile * parent, GFile * root)
GFileInfo *info; GFileInfo *info;
GFile *descend; GFile *descend;
char *relative_path; char *relative_path;
int i; guint i;
gboolean found; gboolean found;
g_assert (root != NULL); g_assert (root != NULL);
@@ -571,7 +575,7 @@ test_enumerate (gconstpointer test_data)
GError *error; GError *error;
GFileEnumerator *enumerator; GFileEnumerator *enumerator;
GFileInfo *info; GFileInfo *info;
int i; guint i;
struct StructureItem item; struct StructureItem item;
@@ -735,7 +739,7 @@ test_copy_move (gconstpointer test_data)
{ {
GFile *root; GFile *root;
gboolean res; gboolean res;
int i; guint i;
struct StructureItem item; struct StructureItem item;
log ("\n"); log ("\n");
@@ -799,7 +803,7 @@ test_create (gconstpointer test_data)
GFile *root, *child; GFile *root, *child;
gboolean res; gboolean res;
GError *error; GError *error;
int i; guint i;
struct StructureItem item; struct StructureItem item;
GFileOutputStream *os; GFileOutputStream *os;
@@ -885,7 +889,7 @@ test_open (gconstpointer test_data)
GFile *root, *child; GFile *root, *child;
gboolean res; gboolean res;
GError *error; GError *error;
int i; guint i;
struct StructureItem item; struct StructureItem item;
GFileInputStream *input_stream; GFileInputStream *input_stream;
@@ -956,7 +960,7 @@ test_delete (gconstpointer test_data)
GFile *child; GFile *child;
gboolean res; gboolean res;
GError *error; GError *error;
int i; guint i;
struct StructureItem item; struct StructureItem item;
g_assert (test_data != NULL); g_assert (test_data != NULL);
@@ -1092,7 +1096,7 @@ int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
static gboolean only_create_struct; static gboolean only_create_struct;
static char *target_path; const char *target_path;
GError *error; GError *error;
GOptionContext *context; GOptionContext *context;

View File

@@ -4,8 +4,8 @@
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <string.h>
static char *original_data = "This is some test data that we can put in a file..."; static const char *original_data = "This is some test data that we can put in a file...";
static char *new_data = "new data.."; static const char *new_data = "new data..";
static void static void
verify_pos (GIOStream *iostream, goffset expected_pos) verify_pos (GIOStream *iostream, goffset expected_pos)
@@ -123,7 +123,7 @@ verify_iostream (GFileIOStream *file_iostream)
static void static void
test_g_file_open_readwrite (void) test_g_file_open_readwrite (void)
{ {
char *tmpfile; char *tmp_file;
int fd; int fd;
gboolean res; gboolean res;
GFileIOStream *file_iostream; GFileIOStream *file_iostream;
@@ -132,11 +132,11 @@ test_g_file_open_readwrite (void)
GError *error; GError *error;
fd = g_file_open_tmp ("readwrite_XXXXXX", fd = g_file_open_tmp ("readwrite_XXXXXX",
&tmpfile, NULL); &tmp_file, NULL);
g_assert (fd != -1); g_assert (fd != -1);
close (fd); close (fd);
res = g_file_set_contents (tmpfile, res = g_file_set_contents (tmp_file,
original_data, -1, NULL); original_data, -1, NULL);
g_assert (res); g_assert (res);
@@ -150,7 +150,7 @@ test_g_file_open_readwrite (void)
g_error_free (error); g_error_free (error);
g_object_unref (file); g_object_unref (file);
file = g_file_new_for_path (tmpfile); file = g_file_new_for_path (tmp_file);
error = NULL; error = NULL;
file_iostream = g_file_open_readwrite (file, NULL, &error); file_iostream = g_file_open_readwrite (file, NULL, &error);
g_assert (file_iostream != NULL); g_assert (file_iostream != NULL);
@@ -159,14 +159,14 @@ test_g_file_open_readwrite (void)
g_object_unref (file_iostream); g_object_unref (file_iostream);
g_unlink (tmpfile); g_unlink (tmp_file);
g_free (tmpfile); g_free (tmpfile);
} }
static void static void
test_g_file_create_readwrite (void) test_g_file_create_readwrite (void)
{ {
char *tmpfile; char *tmp_file;
int fd; int fd;
gboolean res; gboolean res;
GFileIOStream *file_iostream; GFileIOStream *file_iostream;
@@ -176,17 +176,17 @@ test_g_file_create_readwrite (void)
gsize n_bytes; gsize n_bytes;
fd = g_file_open_tmp ("readwrite_XXXXXX", fd = g_file_open_tmp ("readwrite_XXXXXX",
&tmpfile, NULL); &tmp_file, NULL);
g_assert (fd != -1); g_assert (fd != -1);
close (fd); close (fd);
file = g_file_new_for_path (tmpfile); file = g_file_new_for_path (tmp_file);
error = NULL; error = NULL;
file_iostream = g_file_create_readwrite (file, 0, NULL, &error); file_iostream = g_file_create_readwrite (file, 0, NULL, &error);
g_assert (file_iostream == NULL); g_assert (file_iostream == NULL);
g_assert (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS)); g_assert (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS));
g_unlink (tmpfile); g_unlink (tmp_file);
file_iostream = g_file_create_readwrite (file, 0, NULL, &error); file_iostream = g_file_create_readwrite (file, 0, NULL, &error);
g_assert (file_iostream != NULL); g_assert (file_iostream != NULL);
@@ -205,14 +205,14 @@ test_g_file_create_readwrite (void)
g_object_unref (file_iostream); g_object_unref (file_iostream);
g_unlink (tmpfile); g_unlink (tmp_file);
g_free (tmpfile); g_free (tmp_file);
} }
static void static void
test_g_file_replace_readwrite (void) test_g_file_replace_readwrite (void)
{ {
char *tmpfile, *backup, *data; char *tmp_file, *backup, *data;
int fd; int fd;
gboolean res; gboolean res;
GFileIOStream *file_iostream; GFileIOStream *file_iostream;
@@ -224,15 +224,15 @@ test_g_file_replace_readwrite (void)
gsize n_bytes; gsize n_bytes;
fd = g_file_open_tmp ("readwrite_XXXXXX", fd = g_file_open_tmp ("readwrite_XXXXXX",
&tmpfile, NULL); &tmp_file, NULL);
g_assert (fd != -1); g_assert (fd != -1);
close (fd); close (fd);
res = g_file_set_contents (tmpfile, res = g_file_set_contents (tmp_file,
new_data, -1, NULL); new_data, -1, NULL);
g_assert (res); g_assert (res);
file = g_file_new_for_path (tmpfile); file = g_file_new_for_path (tmp_file);
error = NULL; error = NULL;
file_iostream = g_file_replace_readwrite (file, NULL, file_iostream = g_file_replace_readwrite (file, NULL,
TRUE, 0, NULL, &error); TRUE, 0, NULL, &error);
@@ -260,7 +260,7 @@ test_g_file_replace_readwrite (void)
g_object_unref (file_iostream); g_object_unref (file_iostream);
backup = g_strconcat (tmpfile, "~", NULL); backup = g_strconcat (tmp_file, "~", NULL);
res = g_file_get_contents (backup, res = g_file_get_contents (backup,
&data, &data,
NULL, NULL); NULL, NULL);
@@ -270,8 +270,8 @@ test_g_file_replace_readwrite (void)
g_unlink (backup); g_unlink (backup);
g_free (backup); g_free (backup);
g_unlink (tmpfile); g_unlink (tmp_file);
g_free (tmpfile); g_free (tmp_file);
} }

View File

@@ -37,7 +37,7 @@ static GCancellable *cancellable;
static GMainLoop *loop; static GMainLoop *loop;
static int nlookups = 0; static int nlookups = 0;
static void static void G_GNUC_NORETURN
usage (void) usage (void)
{ {
fprintf (stderr, "Usage: resolver [-t] [-s] [hostname | IP | service/protocol/domain ] ...\n"); fprintf (stderr, "Usage: resolver [-t] [-s] [hostname | IP | service/protocol/domain ] ...\n");
@@ -417,9 +417,9 @@ interrupted (int sig)
} }
static gboolean static gboolean
async_cancel (GIOChannel *source, GIOCondition cond, gpointer cancellable) async_cancel (GIOChannel *source, GIOCondition cond, gpointer cancel)
{ {
g_cancellable_cancel (cancellable); g_cancellable_cancel (cancel);
return FALSE; return FALSE;
} }
#endif #endif

View File

@@ -21,7 +21,7 @@ static gchar *
cook_piece (void) cook_piece (void)
{ {
char buffer[MAX_PIECE_SIZE * 2]; char buffer[MAX_PIECE_SIZE * 2];
gint symbols, index = 0; gint symbols, i = 0;
symbols = g_test_rand_int_range (1, MAX_PIECE_SIZE + 1); symbols = g_test_rand_int_range (1, MAX_PIECE_SIZE + 1);
@@ -32,26 +32,26 @@ cook_piece (void)
switch (c) switch (c)
{ {
case 26: case 26:
buffer[index++] = '\n'; buffer[i++] = '\n';
case 27: case 27:
buffer[index++] = '\r'; buffer[i++] = '\r';
break; break;
case 28: case 28:
buffer[index++] = '\r'; buffer[i++] = '\r';
case 29: case 29:
buffer[index++] = '\n'; buffer[i++] = '\n';
break; break;
default: default:
buffer[index++] = c + 'a'; buffer[i++] = c + 'a';
break; break;
} }
g_assert_cmpint (index, <=, sizeof buffer); g_assert_cmpint (i, <=, sizeof buffer);
} }
return g_strndup (buffer, index); return g_strndup (buffer, i);
} }
static gchar ** static gchar **
@@ -83,6 +83,8 @@ typedef struct
typedef GInputStreamClass SleepyStreamClass; typedef GInputStreamClass SleepyStreamClass;
GType sleepy_stream_get_type (void);
G_DEFINE_TYPE (SleepyStream, sleepy_stream, G_TYPE_INPUT_STREAM) G_DEFINE_TYPE (SleepyStream, sleepy_stream, G_TYPE_INPUT_STREAM)
static gssize static gssize
@@ -149,7 +151,7 @@ sleepy_stream_class_init (SleepyStreamClass *class)
*/ */
} }
SleepyStream * static SleepyStream *
sleepy_stream_new (void) sleepy_stream_new (void)
{ {
return g_object_new (sleepy_stream_get_type (), NULL); return g_object_new (sleepy_stream_get_type (), NULL);
@@ -197,7 +199,7 @@ build_comparison (GString *str,
} }
void static void
test (void) test (void)
{ {
SleepyStream *stream = sleepy_stream_new (); SleepyStream *stream = sleepy_stream_new ();
@@ -259,7 +261,7 @@ asynch_ready (GObject *object,
} }
void static void
asynch (void) asynch (void)
{ {
SleepyStream *sleepy = sleepy_stream_new (); SleepyStream *sleepy = sleepy_stream_new ();

View File

@@ -35,12 +35,12 @@ socket_address_to_string (GSocketAddress *address)
{ {
GInetAddress *inet_address; GInetAddress *inet_address;
char *str, *res; char *str, *res;
int port; int the_port;
inet_address = g_inet_socket_address_get_address (G_INET_SOCKET_ADDRESS (address)); inet_address = g_inet_socket_address_get_address (G_INET_SOCKET_ADDRESS (address));
str = g_inet_address_to_string (inet_address); str = g_inet_address_to_string (inet_address);
port = g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (address)); the_port = g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (address));
res = g_strdup_printf ("%s:%d", str, port); res = g_strdup_printf ("%s:%d", str, the_port);
g_free (str); g_free (str);
return res; return res;
} }

View File

@@ -94,7 +94,8 @@ test_srv_target_ordering (void)
{ {
GList *targets, *sorted, *t; GList *targets, *sorted, *t;
char result[7], *p; char result[7], *p;
int i, o; int i;
guint o;
targets = NULL; targets = NULL;
/* name, port, priority, weight */ /* name, port, priority, weight */

View File

@@ -48,7 +48,7 @@ writer_thread (gpointer user_data)
g_usleep (10); g_usleep (10);
offset = 0; offset = 0;
while (offset < sizeof (DATA)) while (offset < (gssize) sizeof (DATA))
{ {
nwrote = g_output_stream_write (out, DATA + offset, nwrote = g_output_stream_write (out, DATA + offset,
sizeof (DATA) - offset, sizeof (DATA) - offset,
@@ -86,7 +86,7 @@ reader_thread (gpointer user_data)
do do
{ {
total = 0; total = 0;
while (total < sizeof (DATA)) while (total < (gssize) sizeof (DATA))
{ {
nread = g_input_stream_read (in, buf + total, sizeof (buf) - total, nread = g_input_stream_read (in, buf + total, sizeof (buf) - total,
reader_cancel, &err); reader_cancel, &err);