From 1b532b5fdc564eae906a47402849087da4edf9f8 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 29 Mar 2018 12:09:10 +0200 Subject: [PATCH] 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. --- src/nm-core-utils.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/nm-core-utils.c b/src/nm-core-utils.c index 7c36596d0a..2a50f8f816 100644 --- a/src/nm-core-utils.c +++ b/src/nm-core-utils.c @@ -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);