Merge branch 'fix_warnings' into 'master'

Fix signedness warnings

See merge request GNOME/glib!1699
This commit is contained in:
Philip Withnall 2020-11-14 11:51:55 +00:00
commit c97827c353
13 changed files with 35 additions and 40 deletions

View File

@ -194,8 +194,7 @@ append_tuple_type_string (GString *string,
{
GVariantType *result, *other_result;
GVariantType **types;
gint size;
gsize i;
gsize i, size;
g_string_append_c (string, '(');
g_string_append (description, "t of [");
@ -376,8 +375,7 @@ describe_type (const GVariantType *type)
{
const GVariantType *sub;
GString *string;
gint length;
gsize i;
gsize i, length;
string = g_string_new ("t of [");
@ -873,8 +871,7 @@ describe_info (GVariantTypeInfo *info)
{
const gchar *sep = "";
GString *string;
gint length;
gsize i;
gsize i, length;
string = g_string_new ("t of [");
length = g_variant_type_info_n_members (info);
@ -935,11 +932,10 @@ static void
check_offsets (GVariantTypeInfo *info,
const GVariantType *type)
{
gsize flavour;
gint length;
gsize flavour, length;
length = g_variant_type_info_n_members (info);
g_assert_cmpint (length, ==, g_variant_type_n_items (type));
g_assert_cmpuint (length, ==, g_variant_type_n_items (type));
/* the 'flavour' is the low order bits of the ending point of
* variable-size items in the tuple. this lets us test that the type
@ -2637,7 +2633,7 @@ tree_instance_check_gvariant (TreeInstance *tree,
break;
case 'b':
return g_variant_get_boolean (value) == tree->data.integer;
return g_variant_get_boolean (value) == (gboolean) tree->data.integer;
case 'y':
return g_variant_get_byte (value) == (guchar) tree->data.integer;
@ -3091,7 +3087,7 @@ test_varargs (void)
i = 0;
g_variant_iter_init (&iter, value);
while (g_variant_iter_loop (&iter, "mi", NULL, &val))
g_assert_true (val == i++ || val == 0);
g_assert_true (val == (gint) i++ || val == 0);
g_assert_cmpuint (i, ==, 100);
i = 0;

View File

@ -591,7 +591,7 @@ test_hash_misc (void)
gint value = 120;
gint *pvalue;
GList *keys, *values;
gint keys_len, values_len;
gsize keys_len, values_len;
GHashTableIter iter;
gpointer ikey, ivalue;
int result_array[10000];

View File

@ -398,7 +398,7 @@ compare_field (const GLogField *f1, const GLogField *f2)
static gboolean
compare_fields (const GLogField *f1, gsize n1, const GLogField *f2, gsize n2)
{
int i, j;
gsize i, j;
for (i = 0; i < n1; i++)
{

View File

@ -220,14 +220,14 @@ test_cleanup (void)
int
main (int argc, char **argv)
{
int i;
gsize i;
gchar *path;
g_test_init (&argc, &argv, NULL);
for (i = 0; i < G_N_ELEMENTS (tests); i++)
{
path = g_strdup_printf ("/markup/collect/%d", i);
path = g_strdup_printf ("/markup/collect/%" G_GSIZE_FORMAT, i);
g_test_add_data_func (path, &tests[i], test_collect);
g_free (path);
}

View File

@ -144,21 +144,21 @@ format_test (void)
int main (int argc, char **argv)
{
gint i;
gsize i;
gchar *path;
g_test_init (&argc, &argv, NULL);
for (i = 0; i < G_N_ELEMENTS (escape_tests); i++)
{
path = g_strdup_printf ("/markup/escape-text/%d", i);
path = g_strdup_printf ("/markup/escape-text/%" G_GSIZE_FORMAT, i);
g_test_add_data_func (path, &escape_tests[i], escape_test);
g_free (path);
}
for (i = 0; i < G_N_ELEMENTS (unichar_tests); i++)
{
path = g_strdup_printf ("/markup/escape-unichar/%d", i);
path = g_strdup_printf ("/markup/escape-unichar/%" G_GSIZE_FORMAT, i);
g_test_add_data_func (path, &unichar_tests[i], unichar_test);
g_free (path);
}

View File

@ -168,7 +168,7 @@ traversal_test (void)
{ G_LEVEL_ORDER, G_TRAVERSE_ALL, 3, 7, "ABFCDEG" },
{ G_LEVEL_ORDER, G_TRAVERSE_ALL, 3, 8, "ABFCDEG" },
};
gint i;
gsize i;
CallbackData data;
root = g_node_new (C2P ('A'));

View File

@ -173,7 +173,7 @@ thread_func (gpointer data)
static void
test_once_init_multi_threaded (void)
{
gint i;
gsize i;
GThread *threads[THREADS];
g_test_summary ("Test g_once_init_{enter,leave}() usage from multiple threads");

View File

@ -210,28 +210,28 @@ test_equal (gconstpointer d)
int
main (int argc, char** argv)
{
gint i;
gsize i;
gchar *path;
g_test_init (&argc, &argv, NULL);
for (i = 0; i < G_N_ELEMENTS (compile_tests); i++)
{
path = g_strdup_printf ("/pattern/compile/%d", i);
path = g_strdup_printf ("/pattern/compile/%" G_GSIZE_FORMAT, i);
g_test_add_data_func (path, &compile_tests[i], test_compilation);
g_free (path);
}
for (i = 0; i < G_N_ELEMENTS (match_tests); i++)
{
path = g_strdup_printf ("/pattern/match/%d", i);
path = g_strdup_printf ("/pattern/match/%" G_GSIZE_FORMAT, i);
g_test_add_data_func (path, &match_tests[i], test_match);
g_free (path);
}
for (i = 0; i < G_N_ELEMENTS (equal_tests); i++)
{
path = g_strdup_printf ("/pattern/equal/%d", i);
path = g_strdup_printf ("/pattern/equal/%" G_GSIZE_FORMAT, i);
g_test_add_data_func (path, &equal_tests[i], test_equal);
g_free (path);
}

View File

@ -246,7 +246,7 @@ test_error (void)
"/glib/testing/protocol/critical",
"/glib/testing/protocol/error"
};
gint i;
gsize i;
int messages = 0;
for (i = 0; i < G_N_ELEMENTS (tests); i++)

View File

@ -14,7 +14,7 @@ check_integrity (GQueue *queue)
GList *last;
GList *links;
GList *link;
gint n;
guint n;
g_assert (queue->length < 4000000000u);
@ -266,7 +266,7 @@ random_test (gconstpointer d)
break;
case GET_LENGTH:
{
int l;
guint l;
l = g_queue_get_length (q);
@ -416,13 +416,13 @@ random_test (gconstpointer d)
int n = get_random_position (q, TRUE);
gpointer elm = g_queue_peek_nth (q, n);
if (n == q->length - 1)
if (n == (int) (q->length - 1))
qinf->tail = qinf->tail->prev;
if (n == 0)
qinf->head = qinf->head->next;
if (n >= 0 && n < q->length)
if (n >= 0 && (guint) n < q->length)
qinf->length--;
g_assert (elm == g_queue_pop_nth (q, n));
@ -450,7 +450,7 @@ random_test (gconstpointer d)
{
GList *list;
int n = get_random_position (q, TRUE);
if (n < 0 || n >= q->length)
if (n < 0 || (guint) n >= q->length)
{
g_assert (g_queue_peek_nth (q, n) == NULL);
}
@ -637,7 +637,7 @@ random_test (gconstpointer d)
{
int n = get_random_position (q, FALSE);
if (n == g_queue_get_length (q) - 1)
if (n == (int) (g_queue_get_length (q) - 1))
qinf->tail = qinf->tail->prev;
if (n == 0)

View File

@ -241,7 +241,7 @@ test_rcbox_alignment (void)
sizeof (gint32) * 3,
};
int i;
gsize i;
for (i = 0; i < G_N_ELEMENTS (block_sizes); i++)
{
@ -265,7 +265,7 @@ test_atomic_rcbox_alignment (void)
sizeof (gint32) * 3,
};
int i;
gsize i;
for (i = 0; i < G_N_ELEMENTS (block_sizes); i++)
{

View File

@ -1305,8 +1305,7 @@ test_match_all (gconstpointer d)
GMatchInfo *match_info;
GSList *l_exp;
gboolean match_ok;
gint match_count;
gint i;
guint i, match_count;
regex = g_regex_new (data->pattern, 0, 0, NULL);
match_ok = g_regex_match_all (regex, data->string, 0, &match_info);
@ -1331,7 +1330,7 @@ test_match_all (gconstpointer d)
matched_string = g_match_info_fetch (match_info, i);
g_match_info_fetch_pos (match_info, i, &start, &end);
g_message ("%d. %d-%d '%s'", i, start, end, matched_string);
g_message ("%u. %d-%d '%s'", i, start, end, matched_string);
g_free (matched_string);
}
@ -1342,11 +1341,11 @@ test_match_all (gconstpointer d)
{
Match *exp = l_exp->data;
g_message ("%d. %d-%d '%s'", i, exp->start, exp->end, exp->string);
g_message ("%u. %d-%d '%s'", i, exp->start, exp->end, exp->string);
i++;
}
g_error ("match_count not as expected: %d != %d",
g_error ("match_count not as expected: %u != %d",
match_count, g_slist_length (data->expected));
}

View File

@ -111,8 +111,8 @@ test_scanner_tokens (ScannerFixture *fix,
gchar buf[] = "(\t\n\r\\){}";
const gint buflen = strlen (buf);
gchar tokbuf[] = "(\\){}";
const gint tokbuflen = strlen (tokbuf);
guint i;
const gsize tokbuflen = strlen (tokbuf);
gsize i;
g_scanner_input_text (fix->scanner, buf, buflen);