Merge branch 'fix_more_warnings' into 'master'

Fix more warnings

See merge request GNOME/glib!1957
This commit is contained in:
Sebastian Dröge 2021-04-05 10:42:33 +00:00
commit 9dac3ff498
7 changed files with 27 additions and 17 deletions

View File

@ -731,7 +731,7 @@ print_help (const char *envvar,
{
GList *l;
GIOExtension *extension;
int width = 0;
gsize width = 0;
for (l = g_io_extension_point_get_extensions (ep); l; l = l->next)
{
@ -743,7 +743,9 @@ print_help (const char *envvar,
{
extension = l->data;
g_print (" %*s - %d\n", width, g_io_extension_get_name (extension), g_io_extension_get_priority (extension));
g_print (" %*s - %d\n", (int) MIN (width, G_MAXINT),
g_io_extension_get_name (extension),
g_io_extension_get_priority (extension));
}
}
}

View File

@ -180,17 +180,18 @@ elf_foreach_resource_section (Elf *elf,
SectionCallback callback,
gpointer data)
{
int ret;
size_t shstrndx, shnum;
size_t scnidx;
Elf_Scn *scn;
GElf_Shdr *shdr, shdr_mem;
const gchar *section_name;
elf_getshdrstrndx (elf, &shstrndx);
g_assert (shstrndx >= 0);
ret = elf_getshdrstrndx (elf, &shstrndx);
g_assert (ret == 0);
elf_getshdrnum (elf, &shnum);
g_assert (shnum >= 0);
ret = elf_getshdrnum (elf, &shnum);
g_assert (ret == 0);
for (scnidx = 1; scnidx < shnum; scnidx++)
{

View File

@ -191,13 +191,16 @@ static void
gsettings_list_children (void)
{
gchar **children;
gint max = 0;
gsize max = 0;
gint i;
children = g_settings_list_children (global_settings);
for (i = 0; children[i]; i++)
if (strlen (children[i]) > max)
max = strlen (children[i]);
{
gsize len = strlen (children[i]);
if (len > max)
max = len;
}
for (i = 0; children[i]; i++)
{
@ -212,9 +215,11 @@ gsettings_list_children (void)
NULL);
if (g_settings_schema_get_path (schema) != NULL)
g_print ("%-*s %s\n", max, children[i], g_settings_schema_get_id (schema));
g_print ("%-*s %s\n", (int) MIN (max, G_MAXINT), children[i],
g_settings_schema_get_id (schema));
else
g_print ("%-*s %s:%s\n", max, children[i], g_settings_schema_get_id (schema), path);
g_print ("%-*s %s:%s\n", (int) MIN (max, G_MAXINT), children[i],
g_settings_schema_get_id (schema), path);
g_object_unref (child);
g_settings_schema_unref (schema);

View File

@ -214,7 +214,8 @@ g_unix_socket_address_to_native (GSocketAddress *address,
gssize socklen;
socklen = g_unix_socket_address_get_native_size (address);
if (destlen < socklen)
g_assert (socklen >= 0);
if (destlen < (gsize) socklen)
{
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NO_SPACE,
_("Not enough space for socket address"));

View File

@ -363,7 +363,7 @@ test_tree (void)
const gchar *path;
GFile *file;
gchar **types;
gint i;
gsize i;
#ifdef __APPLE__
g_test_skip ("The OSX backend does not implement g_content_type_guess_for_tree()");

View File

@ -360,7 +360,8 @@ test_context_specific_emit (void)
{
GThread *threads[N_THREADS];
gboolean exited = FALSE;
guint i, n;
gsize i;
gint k, n;
for (i = 0; i < N_THREADS; i++)
threads[i] = g_thread_new ("test", test_emit_thread, &observed_values[i]);
@ -368,7 +369,7 @@ test_context_specific_emit (void)
/* make changes and ensure that they are observed */
for (n = 0; n < 1000; n++)
{
guint64 expiry;
gint64 expiry;
/* don't burn CPU forever */
expiry = g_get_monotonic_time () + 10 * G_TIME_SPAN_SECOND;
@ -376,7 +377,7 @@ test_context_specific_emit (void)
g_atomic_int_set (&current_value, n);
/* wake them to notice */
for (i = 0; i < g_test_rand_int_range (1, 5); i++)
for (k = 0; k < g_test_rand_int_range (1, 5); k++)
g_context_specific_group_emit (&group, g_signal_lookup ("changed", per_thread_thing_get_type ()));
for (i = 0; i < N_THREADS; i++)

View File

@ -1207,7 +1207,7 @@ main (int argc,
{ "/converter-input-stream/charset/fallbacks", "UTF-8", "Some characters just don't fit into latin1: πא", "ISO-8859-1", "Some characters just don't fit into latin1: \\CF\\80\\D7\\90", 4 },
};
gint i;
gsize i;
g_test_init (&argc, &argv, NULL);