mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-05-29 00:40:07 +02:00
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:
parent
4d49fc8222
commit
a5682aff2e
@ -1950,13 +1950,14 @@ g_option_context_parse (GOptionContext *context,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* short option */
|
{ /* short option */
|
||||||
gint new_i = i, arg_length;
|
gint new_i = i;
|
||||||
|
size_t arg_length;
|
||||||
gboolean *nulled_out = NULL;
|
gboolean *nulled_out = NULL;
|
||||||
gboolean has_h_entry = context_has_h_entry (context);
|
gboolean has_h_entry = context_has_h_entry (context);
|
||||||
arg = (*argv)[i] + 1;
|
arg = (*argv)[i] + 1;
|
||||||
arg_length = strlen (arg);
|
arg_length = strlen (arg);
|
||||||
nulled_out = g_newa0 (gboolean, arg_length);
|
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] == '?' ||
|
if (context->help_enabled && (arg[j] == '?' ||
|
||||||
(arg[j] == 'h' && !has_h_entry)))
|
(arg[j] == 'h' && !has_h_entry)))
|
||||||
@ -1995,7 +1996,7 @@ g_option_context_parse (GOptionContext *context,
|
|||||||
{
|
{
|
||||||
gchar *new_arg = NULL;
|
gchar *new_arg = NULL;
|
||||||
gint arg_index = 0;
|
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])
|
if (!nulled_out[j])
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user