core: minor cleanup of nm_utils_g_value_set_strv()

Add some assertion, use an unsigned loop variable (that matches
GPtrArray.len type), and add a comment.
This commit is contained in:
Thomas Haller 2018-03-29 12:09:10 +02:00
parent a5e9980b34
commit 1b532b5fdc

View file

@ -3650,7 +3650,8 @@ nm_utils_setpgid (gpointer unused G_GNUC_UNUSED)
/**
* nm_utils_g_value_set_strv:
* @value: a #GValue, initialized to store a #G_TYPE_STRV
* @strings: a #GPtrArray of strings
* @strings: a #GPtrArray of strings. %NULL values are not
* allowed.
*
* Converts @strings to a #GStrv and stores it in @value.
*/
@ -3658,11 +3659,13 @@ void
nm_utils_g_value_set_strv (GValue *value, GPtrArray *strings)
{
char **strv;
int i;
guint i;
strv = g_new (char *, strings->len + 1);
for (i = 0; i < strings->len; i++)
for (i = 0; i < strings->len; i++) {
nm_assert (strings->pdata[i]);
strv[i] = g_strdup (strings->pdata[i]);
}
strv[i] = NULL;
g_value_take_boxed (value, strv);