[glib: 10/15] Fix signedness warnings in glib/tests/option-context.c




commit 75ba0e552daeda071a12da94cd96248951832d38
Author: Emmanuel Fleury <emmanuel fleury gmail com>
Date:   Sun Nov 8 22:07:56 2020 +0100

    Fix signedness warnings in glib/tests/option-context.c
    
    glib/tests/option-context.c: In function ‘test_group_captions’:
    glib/tests/option-context.c:123:21: error: comparison of integer expressions of different signedness: 
‘gint’ {aka ‘int’} and ‘long unsigned int’
      123 |       for (j = 0; j < G_N_ELEMENTS (test_name_base); ++j)
          |                     ^
    
    glib/tests/option-context.c: In function ‘option_context_parse_command_line’:
    glib/tests/option-context.c:2364:46: error: operand of ‘?:’ changes signedness from ‘int’ to ‘guint’ {aka 
‘unsigned int’} due to unsignedness of other operand
     2364 |   return success ? argv_len - argv_new_len : -1;
          |                                              ^~

 glib/tests/option-context.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/glib/tests/option-context.c b/glib/tests/option-context.c
index 149d22353..4ae050214 100644
--- a/glib/tests/option-context.c
+++ b/glib/tests/option-context.c
@@ -111,7 +111,8 @@ test_group_captions (void)
 {
   const gchar *test_name_base[] = { "help", "help-all", "help-test" };
   gchar *test_name;
-  gint i, j;
+  guint i;
+  gsize j;
 
   g_test_bug ("504142");
 
@@ -132,7 +133,7 @@ test_group_captions (void)
           if (g_test_verbose ())
             trap_flags |= G_TEST_SUBPROCESS_INHERIT_STDOUT | G_TEST_SUBPROCESS_INHERIT_STDERR;
 
-          test_name = g_strdup_printf ("/option/group/captions/subprocess/%s-%d",
+          test_name = g_strdup_printf ("/option/group/captions/subprocess/%s-%u",
                                        test_name_base[j], i);
           g_test_trap_subprocess (test_name, 0, trap_flags);
           g_free (test_name);
@@ -2361,7 +2362,7 @@ option_context_parse_command_line (GOptionContext *context,
   argv_new_len = g_strv_length (argv);
 
   g_strfreev (argv);
-  return success ? argv_len - argv_new_len : -1;
+  return success ? (gint) (argv_len - argv_new_len) : -1;
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]