Skip to content
This repository has been archived by the owner on Nov 17, 2020. It is now read-only.

Commit

Permalink
fix warnings from gcc compilation with my mad CFLAGS
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamin-otte committed Jun 29, 2009
1 parent 4b8ad50 commit afd63c3
Show file tree
Hide file tree
Showing 12 changed files with 119 additions and 106 deletions.
32 changes: 19 additions & 13 deletions gio/tests/data-input-stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@ enum TestDataType {
TEST_DATA_UINT64
};

#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 ))))))
#define TEST_DATA_RETYPE_BUFF(a, t, v) \
(a == TEST_DATA_BYTE ? (t) *(guchar*)v : \
(a == TEST_DATA_INT16 ? (t) *(gint16*)v : \
(a == TEST_DATA_UINT16 ? (t) *(guint16*)v : \
(a == TEST_DATA_INT32 ? (t) *(gint32*)v : \
(a == TEST_DATA_UINT32 ? (t) *(guint32*)v : \
(a == TEST_DATA_INT64 ? (t) *(gint64*)v : \
(t) *(guint64*)v ))))))


static void
Expand Down Expand Up @@ -216,6 +216,9 @@ test_data_array (GInputStream *stream, GInputStream *base_stream,
case TEST_DATA_UINT64:
data_size = 8;
break;
default:
g_assert_not_reached ();
break;
}

/* Set flag to swap bytes if needed */
Expand Down Expand Up @@ -260,9 +263,12 @@ test_data_array (GInputStream *stream, GInputStream *base_stream,
if (swap)
data = (guint64)GUINT64_SWAP_LE_BE((guint64)data);
break;
default:
g_assert_not_reached ();
break;
}
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;
}
Expand All @@ -276,19 +282,19 @@ test_read_int (void)
{
GInputStream *stream;
GInputStream *base_stream;
GRand *rand;
GRand *randomizer;
int i;
gpointer buffer;

rand = g_rand_new ();
randomizer = g_rand_new ();
buffer = g_malloc0 (MAX_BYTES);

/* Fill in some random data */
for (i = 0; i < MAX_BYTES; i++)
{
guchar x = 0;
while (! x)
x = (guchar)g_rand_int (rand);
x = (guchar)g_rand_int (randomizer);
*(guchar*)((guchar*)buffer + sizeof(guchar) * i) = x;
}

Expand All @@ -308,7 +314,7 @@ test_read_int (void)

g_object_unref (base_stream);
g_object_unref (stream);
g_rand_free (rand);
g_rand_free (randomizer);
g_free (buffer);
}

Expand Down
66 changes: 33 additions & 33 deletions gio/tests/data-output-stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,23 +109,14 @@ enum TestDataType {
TEST_DATA_UINT64
};

#define TEST_DATA_RETYPE(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 ))))))

#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 ))))))
#define TEST_DATA_RETYPE_BUFF(a, t, v) \
(a == TEST_DATA_BYTE ? (t) *(guchar*)v : \
(a == TEST_DATA_INT16 ? (t) *(gint16*)v : \
(a == TEST_DATA_UINT16 ? (t) *(guint16*)v : \
(a == TEST_DATA_INT32 ? (t) *(gint32*)v : \
(a == TEST_DATA_UINT32 ? (t) *(guint32*)v : \
(a == TEST_DATA_INT64 ? (t) *(gint64*)v : \
(t) *(guint64*)v ))))))



Expand Down Expand Up @@ -171,6 +162,9 @@ test_data_array (gpointer buffer, int len,
case TEST_DATA_UINT64:
data_size = 8;
break;
default:
g_assert_not_reached ();
break;
}

/* Set flag to swap bytes if needed */
Expand All @@ -184,26 +178,29 @@ test_data_array (gpointer buffer, int len,
switch (data_type)
{
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;
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;
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;
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;
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;
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;
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;
}
g_assert_no_error (error);
g_assert_cmpint (res, ==, TRUE);
Expand All @@ -216,7 +213,7 @@ test_data_array (gpointer buffer, int len,
data = 0;
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)
{
switch (data_type)
Expand All @@ -225,19 +222,22 @@ test_data_array (gpointer buffer, int len,
break;
case TEST_DATA_UINT16:
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;
case TEST_DATA_UINT32:
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;
case TEST_DATA_UINT64:
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;
}
}
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;

pos += data_size;
Expand All @@ -251,18 +251,18 @@ test_data_array (gpointer buffer, int len,
static void
test_read_int (void)
{
GRand *rand;
GRand *randomizer;
gpointer buffer;
int i;

rand = g_rand_new ();
randomizer = g_rand_new ();
buffer = g_malloc0(MAX_BYTES_BINARY);

/* Fill in some random data */
for (i = 0; i < MAX_BYTES_BINARY; i++)
{
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;
}

Expand All @@ -273,7 +273,7 @@ test_read_int (void)
test_data_array (buffer, MAX_BYTES_BINARY, j, i);
}

g_rand_free (rand);
g_rand_free (randomizer);
g_free (buffer);
}

Expand Down
4 changes: 2 additions & 2 deletions gio/tests/desktop-app-info.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,11 @@ cleanup_dir_recurse (GFile *parent, GFile *root)
}

static void
cleanup_subdirs (const char *basedir)
cleanup_subdirs (const char *base_dir)
{
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");
cleanup_dir_recurse (file, file);
g_object_unref (file);
Expand Down
16 changes: 8 additions & 8 deletions gio/tests/g-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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/"}
};

int i;
guint 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);
Expand Down Expand Up @@ -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/"}
};

int i;
guint 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);
Expand Down Expand Up @@ -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, ""},
};

int i;
guint i;
for (i = 0; i < G_N_ELEMENTS (dup_paths); i++)
{
gboolean equal = dup_equals (dup_paths[i].use_uri, dup_paths[i].path1);
Expand Down Expand Up @@ -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"},
};

int i;
guint 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);
Expand Down Expand Up @@ -328,7 +328,7 @@ test_g_file_new_for_commandline_arg (void)
GFile *file;
char *resolved;
char *cwd;
int i;
guint i;

for (i = 0; i < G_N_ELEMENTS (arg_data); i++)
{
Expand Down Expand Up @@ -422,7 +422,7 @@ test_g_file_has_prefix (void)
#endif
};

int i;
guint 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);
Expand All @@ -437,7 +437,7 @@ roundtrip_parent_child (const gboolean use_uri, const gboolean under_root_descen
const char *path, const char *dir_holder)
{
GFile *files[6] = {NULL};
int i;
guint i;

if (use_uri)
{
Expand Down Expand Up @@ -497,7 +497,7 @@ test_g_file_get_parent_child (void)
{"dav://www.gtk.org/plan/meetings", FALSE, TRUE, "meetings"},
};

int i;
guint 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);
}
Expand Down
2 changes: 1 addition & 1 deletion gio/tests/httpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ static GOptionEntry cmd_entries[] = {
static void
send_error (GOutputStream *out,
int error_code,
char *reason)
const char *reason)
{
char *res;

Expand Down
Loading

0 comments on commit afd63c3

Please sign in to comment.