goption: Fix string length handling to use size_t type

When parsing command line options, use `size_t` to hold string lengths.
This introduces no functional changes (any strings long enough to fit in
`size_t` but not in `int` will probably hit command line length limits),
but it does fix a `-Wshorten-64-to-32` warning.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #3527
This commit is contained in:
Philip Withnall 2024-11-07 13:49:51 +00:00
parent 4d49fc8222
commit a5682aff2e
No known key found for this signature in database
GPG Key ID: C5C42CFB268637CA

View File

@ -1950,13 +1950,14 @@ g_option_context_parse (GOptionContext *context,
}
else
{ /* short option */
gint new_i = i, arg_length;
gint new_i = i;
size_t arg_length;
gboolean *nulled_out = NULL;
gboolean has_h_entry = context_has_h_entry (context);
arg = (*argv)[i] + 1;
arg_length = strlen (arg);
nulled_out = g_newa0 (gboolean, arg_length);
for (int j = 0; j < arg_length; j++)
for (size_t j = 0; j < arg_length; j++)
{
if (context->help_enabled && (arg[j] == '?' ||
(arg[j] == 'h' && !has_h_entry)))
@ -1995,7 +1996,7 @@ g_option_context_parse (GOptionContext *context,
{
gchar *new_arg = NULL;
gint arg_index = 0;
for (int j = 0; j < arg_length; j++)
for (size_t j = 0; j < arg_length; j++)
{
if (!nulled_out[j])
{