Fix signedness warning in gio/gsettings-tool.c

gio/gsettings-tool.c: In function ‘gsettings_list_children’:
gio/gsettings-tool.c:199:30: error: comparison of integer expressions of different signedness: ‘size_t’ {aka ‘long unsigned int’} and ‘gint’ {aka ‘int’}
  199 |     if (strlen (children[i]) > max)
      |                              ^
This commit is contained in:
Emmanuel Fleury 2020-11-18 20:59:37 +01:00
parent 0214d892ba
commit a7d3ecca77

View File

@ -191,13 +191,16 @@ static void
gsettings_list_children (void) gsettings_list_children (void)
{ {
gchar **children; gchar **children;
gint max = 0; gsize max = 0;
gint i; gint i;
children = g_settings_list_children (global_settings); children = g_settings_list_children (global_settings);
for (i = 0; children[i]; i++) 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++) for (i = 0; children[i]; i++)
{ {
@ -212,9 +215,11 @@ gsettings_list_children (void)
NULL); NULL);
if (g_settings_schema_get_path (schema) != 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 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_object_unref (child);
g_settings_schema_unref (schema); g_settings_schema_unref (schema);