mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 14:36:13 +01:00
fix warnings from gcc compilation with my mad CFLAGS
This commit is contained in:
parent
4b8ad50fc4
commit
afd63c3281
@ -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
|
||||
@ -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 */
|
||||
@ -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;
|
||||
}
|
||||
@ -276,11 +282,11 @@ 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 */
|
||||
@ -288,7 +294,7 @@ test_read_int (void)
|
||||
{
|
||||
guchar x = 0;
|
||||
while (! x)
|
||||
x = (guchar)g_rand_int (rand);
|
||||
x = (guchar)g_rand_int (randomizer);
|
||||
*(guchar*)((guchar*)buffer + sizeof(guchar) * i) = x;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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 ))))))
|
||||
|
||||
|
||||
|
||||
@ -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 */
|
||||
@ -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);
|
||||
@ -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)
|
||||
@ -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;
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
@ -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);
|
||||
@ -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);
|
||||
@ -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);
|
||||
@ -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++)
|
||||
{
|
||||
@ -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);
|
||||
@ -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)
|
||||
{
|
||||
@ -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);
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ static GOptionEntry cmd_entries[] = {
|
||||
static void
|
||||
send_error (GOutputStream *out,
|
||||
int error_code,
|
||||
char *reason)
|
||||
const char *reason)
|
||||
{
|
||||
char *res;
|
||||
|
||||
|
@ -181,7 +181,7 @@ test_create_structure (gconstpointer test_data)
|
||||
GError *error;
|
||||
GFileOutputStream *outs;
|
||||
GDataOutputStream *outds;
|
||||
int i;
|
||||
guint i;
|
||||
struct StructureItem item;
|
||||
|
||||
g_assert (test_data != NULL);
|
||||
@ -220,6 +220,10 @@ test_create_structure (gconstpointer test_data)
|
||||
item.link_to);
|
||||
child = create_symlink (root, item.filename, item.link_to);
|
||||
break;
|
||||
case G_FILE_TYPE_UNKNOWN:
|
||||
case G_FILE_TYPE_SPECIAL:
|
||||
case G_FILE_TYPE_SHORTCUT:
|
||||
case G_FILE_TYPE_MOUNTABLE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -385,7 +389,7 @@ test_initial_structure (gconstpointer test_data)
|
||||
gboolean res;
|
||||
GError *error;
|
||||
GFileInputStream *ins;
|
||||
int i;
|
||||
guint i;
|
||||
GFileInfo *info;
|
||||
guint32 size;
|
||||
guchar *buffer;
|
||||
@ -486,7 +490,7 @@ traverse_recurse_dirs (GFile * parent, GFile * root)
|
||||
GFileInfo *info;
|
||||
GFile *descend;
|
||||
char *relative_path;
|
||||
int i;
|
||||
guint i;
|
||||
gboolean found;
|
||||
|
||||
g_assert (root != NULL);
|
||||
@ -571,7 +575,7 @@ test_enumerate (gconstpointer test_data)
|
||||
GError *error;
|
||||
GFileEnumerator *enumerator;
|
||||
GFileInfo *info;
|
||||
int i;
|
||||
guint i;
|
||||
struct StructureItem item;
|
||||
|
||||
|
||||
@ -735,7 +739,7 @@ test_copy_move (gconstpointer test_data)
|
||||
{
|
||||
GFile *root;
|
||||
gboolean res;
|
||||
int i;
|
||||
guint i;
|
||||
struct StructureItem item;
|
||||
|
||||
log ("\n");
|
||||
@ -799,7 +803,7 @@ test_create (gconstpointer test_data)
|
||||
GFile *root, *child;
|
||||
gboolean res;
|
||||
GError *error;
|
||||
int i;
|
||||
guint i;
|
||||
struct StructureItem item;
|
||||
GFileOutputStream *os;
|
||||
|
||||
@ -885,7 +889,7 @@ test_open (gconstpointer test_data)
|
||||
GFile *root, *child;
|
||||
gboolean res;
|
||||
GError *error;
|
||||
int i;
|
||||
guint i;
|
||||
struct StructureItem item;
|
||||
GFileInputStream *input_stream;
|
||||
|
||||
@ -956,7 +960,7 @@ test_delete (gconstpointer test_data)
|
||||
GFile *child;
|
||||
gboolean res;
|
||||
GError *error;
|
||||
int i;
|
||||
guint i;
|
||||
struct StructureItem item;
|
||||
|
||||
g_assert (test_data != NULL);
|
||||
@ -1092,7 +1096,7 @@ int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
static gboolean only_create_struct;
|
||||
static char *target_path;
|
||||
const char *target_path;
|
||||
GError *error;
|
||||
GOptionContext *context;
|
||||
|
||||
|
@ -4,8 +4,8 @@
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
static char *original_data = "This is some test data that we can put in a file...";
|
||||
static char *new_data = "new data..";
|
||||
static const char *original_data = "This is some test data that we can put in a file...";
|
||||
static const char *new_data = "new data..";
|
||||
|
||||
static void
|
||||
verify_pos (GIOStream *iostream, goffset expected_pos)
|
||||
@ -123,7 +123,7 @@ verify_iostream (GFileIOStream *file_iostream)
|
||||
static void
|
||||
test_g_file_open_readwrite (void)
|
||||
{
|
||||
char *tmpfile;
|
||||
char *tmp_file;
|
||||
int fd;
|
||||
gboolean res;
|
||||
GFileIOStream *file_iostream;
|
||||
@ -132,11 +132,11 @@ test_g_file_open_readwrite (void)
|
||||
GError *error;
|
||||
|
||||
fd = g_file_open_tmp ("readwrite_XXXXXX",
|
||||
&tmpfile, NULL);
|
||||
&tmp_file, NULL);
|
||||
g_assert (fd != -1);
|
||||
close (fd);
|
||||
|
||||
res = g_file_set_contents (tmpfile,
|
||||
res = g_file_set_contents (tmp_file,
|
||||
original_data, -1, NULL);
|
||||
g_assert (res);
|
||||
|
||||
@ -150,7 +150,7 @@ test_g_file_open_readwrite (void)
|
||||
g_error_free (error);
|
||||
g_object_unref (file);
|
||||
|
||||
file = g_file_new_for_path (tmpfile);
|
||||
file = g_file_new_for_path (tmp_file);
|
||||
error = NULL;
|
||||
file_iostream = g_file_open_readwrite (file, NULL, &error);
|
||||
g_assert (file_iostream != NULL);
|
||||
@ -159,14 +159,14 @@ test_g_file_open_readwrite (void)
|
||||
|
||||
g_object_unref (file_iostream);
|
||||
|
||||
g_unlink (tmpfile);
|
||||
g_unlink (tmp_file);
|
||||
g_free (tmpfile);
|
||||
}
|
||||
|
||||
static void
|
||||
test_g_file_create_readwrite (void)
|
||||
{
|
||||
char *tmpfile;
|
||||
char *tmp_file;
|
||||
int fd;
|
||||
gboolean res;
|
||||
GFileIOStream *file_iostream;
|
||||
@ -176,17 +176,17 @@ test_g_file_create_readwrite (void)
|
||||
gsize n_bytes;
|
||||
|
||||
fd = g_file_open_tmp ("readwrite_XXXXXX",
|
||||
&tmpfile, NULL);
|
||||
&tmp_file, NULL);
|
||||
g_assert (fd != -1);
|
||||
close (fd);
|
||||
|
||||
file = g_file_new_for_path (tmpfile);
|
||||
file = g_file_new_for_path (tmp_file);
|
||||
error = NULL;
|
||||
file_iostream = g_file_create_readwrite (file, 0, NULL, &error);
|
||||
g_assert (file_iostream == NULL);
|
||||
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);
|
||||
g_assert (file_iostream != NULL);
|
||||
|
||||
@ -205,14 +205,14 @@ test_g_file_create_readwrite (void)
|
||||
|
||||
g_object_unref (file_iostream);
|
||||
|
||||
g_unlink (tmpfile);
|
||||
g_free (tmpfile);
|
||||
g_unlink (tmp_file);
|
||||
g_free (tmp_file);
|
||||
}
|
||||
|
||||
static void
|
||||
test_g_file_replace_readwrite (void)
|
||||
{
|
||||
char *tmpfile, *backup, *data;
|
||||
char *tmp_file, *backup, *data;
|
||||
int fd;
|
||||
gboolean res;
|
||||
GFileIOStream *file_iostream;
|
||||
@ -224,15 +224,15 @@ test_g_file_replace_readwrite (void)
|
||||
gsize n_bytes;
|
||||
|
||||
fd = g_file_open_tmp ("readwrite_XXXXXX",
|
||||
&tmpfile, NULL);
|
||||
&tmp_file, NULL);
|
||||
g_assert (fd != -1);
|
||||
close (fd);
|
||||
|
||||
res = g_file_set_contents (tmpfile,
|
||||
res = g_file_set_contents (tmp_file,
|
||||
new_data, -1, NULL);
|
||||
g_assert (res);
|
||||
|
||||
file = g_file_new_for_path (tmpfile);
|
||||
file = g_file_new_for_path (tmp_file);
|
||||
error = NULL;
|
||||
file_iostream = g_file_replace_readwrite (file, NULL,
|
||||
TRUE, 0, NULL, &error);
|
||||
@ -260,7 +260,7 @@ test_g_file_replace_readwrite (void)
|
||||
|
||||
g_object_unref (file_iostream);
|
||||
|
||||
backup = g_strconcat (tmpfile, "~", NULL);
|
||||
backup = g_strconcat (tmp_file, "~", NULL);
|
||||
res = g_file_get_contents (backup,
|
||||
&data,
|
||||
NULL, NULL);
|
||||
@ -270,8 +270,8 @@ test_g_file_replace_readwrite (void)
|
||||
g_unlink (backup);
|
||||
g_free (backup);
|
||||
|
||||
g_unlink (tmpfile);
|
||||
g_free (tmpfile);
|
||||
g_unlink (tmp_file);
|
||||
g_free (tmp_file);
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,7 +37,7 @@ static GCancellable *cancellable;
|
||||
static GMainLoop *loop;
|
||||
static int nlookups = 0;
|
||||
|
||||
static void
|
||||
static void G_GNUC_NORETURN
|
||||
usage (void)
|
||||
{
|
||||
fprintf (stderr, "Usage: resolver [-t] [-s] [hostname | IP | service/protocol/domain ] ...\n");
|
||||
@ -417,9 +417,9 @@ interrupted (int sig)
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
|
@ -21,7 +21,7 @@ static gchar *
|
||||
cook_piece (void)
|
||||
{
|
||||
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);
|
||||
|
||||
@ -32,26 +32,26 @@ cook_piece (void)
|
||||
switch (c)
|
||||
{
|
||||
case 26:
|
||||
buffer[index++] = '\n';
|
||||
buffer[i++] = '\n';
|
||||
case 27:
|
||||
buffer[index++] = '\r';
|
||||
buffer[i++] = '\r';
|
||||
break;
|
||||
|
||||
case 28:
|
||||
buffer[index++] = '\r';
|
||||
buffer[i++] = '\r';
|
||||
case 29:
|
||||
buffer[index++] = '\n';
|
||||
buffer[i++] = '\n';
|
||||
break;
|
||||
|
||||
default:
|
||||
buffer[index++] = c + 'a';
|
||||
buffer[i++] = c + 'a';
|
||||
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 **
|
||||
@ -83,6 +83,8 @@ typedef struct
|
||||
|
||||
typedef GInputStreamClass SleepyStreamClass;
|
||||
|
||||
GType sleepy_stream_get_type (void);
|
||||
|
||||
G_DEFINE_TYPE (SleepyStream, sleepy_stream, G_TYPE_INPUT_STREAM)
|
||||
|
||||
static gssize
|
||||
@ -149,7 +151,7 @@ sleepy_stream_class_init (SleepyStreamClass *class)
|
||||
*/
|
||||
}
|
||||
|
||||
SleepyStream *
|
||||
static SleepyStream *
|
||||
sleepy_stream_new (void)
|
||||
{
|
||||
return g_object_new (sleepy_stream_get_type (), NULL);
|
||||
@ -197,7 +199,7 @@ build_comparison (GString *str,
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
test (void)
|
||||
{
|
||||
SleepyStream *stream = sleepy_stream_new ();
|
||||
@ -259,7 +261,7 @@ asynch_ready (GObject *object,
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
asynch (void)
|
||||
{
|
||||
SleepyStream *sleepy = sleepy_stream_new ();
|
||||
|
@ -35,12 +35,12 @@ socket_address_to_string (GSocketAddress *address)
|
||||
{
|
||||
GInetAddress *inet_address;
|
||||
char *str, *res;
|
||||
int port;
|
||||
int the_port;
|
||||
|
||||
inet_address = g_inet_socket_address_get_address (G_INET_SOCKET_ADDRESS (address));
|
||||
str = g_inet_address_to_string (inet_address);
|
||||
port = g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (address));
|
||||
res = g_strdup_printf ("%s:%d", str, port);
|
||||
the_port = g_inet_socket_address_get_port (G_INET_SOCKET_ADDRESS (address));
|
||||
res = g_strdup_printf ("%s:%d", str, the_port);
|
||||
g_free (str);
|
||||
return res;
|
||||
}
|
||||
|
@ -94,7 +94,8 @@ test_srv_target_ordering (void)
|
||||
{
|
||||
GList *targets, *sorted, *t;
|
||||
char result[7], *p;
|
||||
int i, o;
|
||||
int i;
|
||||
guint o;
|
||||
|
||||
targets = NULL;
|
||||
/* name, port, priority, weight */
|
||||
|
@ -48,7 +48,7 @@ writer_thread (gpointer user_data)
|
||||
g_usleep (10);
|
||||
|
||||
offset = 0;
|
||||
while (offset < sizeof (DATA))
|
||||
while (offset < (gssize) sizeof (DATA))
|
||||
{
|
||||
nwrote = g_output_stream_write (out, DATA + offset,
|
||||
sizeof (DATA) - offset,
|
||||
@ -86,7 +86,7 @@ reader_thread (gpointer user_data)
|
||||
do
|
||||
{
|
||||
total = 0;
|
||||
while (total < sizeof (DATA))
|
||||
while (total < (gssize) sizeof (DATA))
|
||||
{
|
||||
nread = g_input_stream_read (in, buf + total, sizeof (buf) - total,
|
||||
reader_cancel, &err);
|
||||
|
Loading…
Reference in New Issue
Block a user