From 11d4412ee1554358c629f44eb41b5e8cc3546870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Hor=C3=A1k?= Date: Fri, 20 Sep 2019 16:25:17 +0200 Subject: process s390 specific device info from rd.znet parameter in nm-initrd-generator syntax: rd.znet=,, The s390 specific options used to create the network interface in the kernel are currently not processed by nm-initrd-generator causing incomplete ifcfg file. fixes https://bugzilla.redhat.com/show_bug.cgi?id=1753975 --- src/initrd/nm-initrd-generator.c | 2 +- src/initrd/nmi-cmdline-reader.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/initrd/nm-initrd-generator.c b/src/initrd/nm-initrd-generator.c index bc13ed36e1..e613317197 100644 --- a/src/initrd/nm-initrd-generator.c +++ b/src/initrd/nm-initrd-generator.c @@ -86,7 +86,7 @@ main (int argc, char *argv[]) int errsv; option_context = g_option_context_new ("-- [ip=...] [rd.route=...] [bridge=...] [bond=...] [team=...] [vlan=...] " - "[bootdev=...] [nameserver=...] [rd.peerdns=...] [rd.bootif=...] [BOOTIF=...] ... "); + "[bootdev=...] [nameserver=...] [rd.peerdns=...] [rd.bootif=...] [BOOTIF=...] [rd.znet=...] ... "); g_option_context_set_summary (option_context, "Generate early NetworkManager configuration."); g_option_context_set_description (option_context, diff --git a/src/initrd/nmi-cmdline-reader.c b/src/initrd/nmi-cmdline-reader.c index afb9355897..d3f0f23c08 100644 --- a/src/initrd/nmi-cmdline-reader.c +++ b/src/initrd/nmi-cmdline-reader.c @@ -683,6 +683,37 @@ parse_rd_peerdns (GHashTable *connections, char *argument) NULL); } +static void +parse_rd_znet (GHashTable *connections, char *argument) +{ + const char *nettype = NULL; + const char *tmp = NULL; + const char *subchannels[4] = { 0, 0, 0, 0 }; + NMConnection *connection; + NMSettingWired *s_wired = NULL; + + nettype = get_word (&argument, ','); + subchannels[0] = get_word (&argument, ','); + subchannels[1] = get_word (&argument, ','); + if (g_strcmp0 (nettype, "ctc") != 0) { + subchannels[2] = get_word (&argument, ','); + } + + connection = get_conn (connections, NULL, NULL); + s_wired = nm_connection_get_setting_wired (connection); + g_object_set (s_wired, + NM_SETTING_WIRED_S390_NETTYPE, nettype, + NM_SETTING_WIRED_S390_SUBCHANNELS, &subchannels, + NULL); + + while ((tmp = get_word (&argument, ',')) != NULL) { + gs_strfreev char ** optval = NULL; + + optval = g_strsplit (tmp, "=", 2); + nm_setting_wired_add_s390_option (s_wired, optval[0], optval[1]); + } +} + static void _normalize_conn (gpointer key, gpointer value, gpointer user_data) { @@ -729,6 +760,8 @@ nmi_cmdline_reader_parse (const char *sysfs_dir, char **argv) ignore_bootif = !_nm_utils_ascii_str_to_bool (argument, TRUE); else if (strcmp (tag, "rd.neednet") == 0) neednet = _nm_utils_ascii_str_to_bool (argument, TRUE); + else if (strcmp (tag, "rd.znet") == 0) + parse_rd_znet (connections, argument); else if (strcasecmp (tag, "BOOTIF") == 0) bootif = argument; } -- cgit v1.2.1 From df07539105c2ad1e43f0f7c59adb68e213a78232 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Hor=C3=A1k?= Date: Sat, 21 Sep 2019 17:31:48 +0200 Subject: nm-initrd-generator - add test for rd.znet --- src/initrd/tests/test-cmdline-reader.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/initrd/tests/test-cmdline-reader.c b/src/initrd/tests/test-cmdline-reader.c index 84f01b8a5f..e06c299968 100644 --- a/src/initrd/tests/test-cmdline-reader.c +++ b/src/initrd/tests/test-cmdline-reader.c @@ -789,6 +789,18 @@ test_ignore_extra (void) g_assert_cmpint (g_hash_table_size (connections), ==, 0); } +static void +test_rd_znet (void) +{ + gs_unref_hashtable GHashTable *connections = NULL; + gs_strfreev char **argv = g_strdupv ((char *[]){ "ip=10.11.12.13::10.11.12.1:24:foo.example.com:enc800:none", + "rd.znet=ctc,0.0.0800,0.0.0801,layer2=0,portno=0", NULL }); + + connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv); + g_assert (connections); + g_assert_cmpint (g_hash_table_size (connections), ==, 1); +} + NMTST_DEFINE (); int main (int argc, char **argv) @@ -811,6 +823,7 @@ int main (int argc, char **argv) g_test_add_func ("/initrd/cmdline/bridge/default", test_bridge_default); g_test_add_func ("/initrd/cmdline/ibft", test_ibft); g_test_add_func ("/initrd/cmdline/ignore_extra", test_ignore_extra); + g_test_add_func ("/initrd/cmdline/rd_zdnet", test_rd_znet); return g_test_run (); } -- cgit v1.2.1 From 783fe28465f0879bf27180c86d2f09cf0945c54c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 27 Sep 2019 07:58:58 +0200 Subject: initrd: avoid assertion inparse_rd_znet() and cleanup - nm_setting_wired_add_s390_option() asserts that a "value" argument is given. Check that the string contains a '=' where we can split. - pass the requested NM_SETTING_WIRED_SETTING_NAME type to get_conn(). Otherwise, @s_wired might be %NULL, resulting in an assertion. I do wonder whether this always retrieves a connection of the appropriate type for modification, or whether a profile could be returned that was created for a different purpose. But that isn't changed. - avoid "g_strcmp0 (nettype, "ctc") != 0". I find it unexpected, that we add the 3rd subchannel component, if the nettype is "ctc" (intuitively, I'd expect it to be the opposite). The reasons for this are not documented, but I presume it is correct. Anyway, using streq() makes this slightly more clear to me, as with strcmp() I would wonder whether this was just a typo while with streq() I'd be more confident that this is indeed intended. - don't initialize local variables unnecessarily. The compiler would warn if we would forget about this. Also, don'\''t use { } for a one-line block. --- src/initrd/nmi-cmdline-reader.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/initrd/nmi-cmdline-reader.c b/src/initrd/nmi-cmdline-reader.c index d3f0f23c08..0913574032 100644 --- a/src/initrd/nmi-cmdline-reader.c +++ b/src/initrd/nmi-cmdline-reader.c @@ -686,20 +686,19 @@ parse_rd_peerdns (GHashTable *connections, char *argument) static void parse_rd_znet (GHashTable *connections, char *argument) { - const char *nettype = NULL; - const char *tmp = NULL; + const char *nettype; const char *subchannels[4] = { 0, 0, 0, 0 }; + const char *tmp; NMConnection *connection; - NMSettingWired *s_wired = NULL; + NMSettingWired *s_wired; nettype = get_word (&argument, ','); subchannels[0] = get_word (&argument, ','); subchannels[1] = get_word (&argument, ','); - if (g_strcmp0 (nettype, "ctc") != 0) { + if (!nm_streq0 (nettype, "ctc")) subchannels[2] = get_word (&argument, ','); - } - connection = get_conn (connections, NULL, NULL); + connection = get_conn (connections, NULL, NM_SETTING_WIRED_SETTING_NAME); s_wired = nm_connection_get_setting_wired (connection); g_object_set (s_wired, NM_SETTING_WIRED_S390_NETTYPE, nettype, @@ -707,10 +706,17 @@ parse_rd_znet (GHashTable *connections, char *argument) NULL); while ((tmp = get_word (&argument, ',')) != NULL) { - gs_strfreev char ** optval = NULL; + char *val; - optval = g_strsplit (tmp, "=", 2); - nm_setting_wired_add_s390_option (s_wired, optval[0], optval[1]); + val = strchr (tmp, '='); + if (val) { + gs_free char *key = NULL; + + key = g_strndup (tmp, val - tmp); + val[0] = '\0'; + val++; + nm_setting_wired_add_s390_option (s_wired, key, val); + } } } -- cgit v1.2.1 From 9b3d37721bc2d5ad43125439a03463e08c6835b1 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 27 Sep 2019 08:04:33 +0200 Subject: libnm: fix variable type for holding g_strv_length() result in "nm-setting-wired.c"'s verify() --- libnm-core/nm-setting-wired.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libnm-core/nm-setting-wired.c b/libnm-core/nm-setting-wired.c index 9fd6596119..fee069883e 100644 --- a/libnm-core/nm-setting-wired.c +++ b/libnm-core/nm-setting-wired.c @@ -776,7 +776,7 @@ verify (NMSetting *setting, NMConnection *connection, GError **error) } if (priv->s390_subchannels) { - int len = g_strv_length (priv->s390_subchannels); + guint len = g_strv_length (priv->s390_subchannels); if (len != 2 && len != 3) { g_set_error_literal (error, -- cgit v1.2.1 From 19604cb126247c5cd75039fd9ccd93bcadcd22ed Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 27 Sep 2019 08:36:49 +0200 Subject: initrd: avoid modifying the argv argument in nmi_cmdline_reader_parse() While nmi_cmdline_reader_parse() only has one caller, which indeed has the argv parameter at hand and doesn't care it to be modified, I think it is ugly. Arguments preferably are strictly either input or output arguments, with input arguments not being modified by the call. --- src/initrd/nmi-cmdline-reader.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/initrd/nmi-cmdline-reader.c b/src/initrd/nmi-cmdline-reader.c index 0913574032..9d59b26284 100644 --- a/src/initrd/nmi-cmdline-reader.c +++ b/src/initrd/nmi-cmdline-reader.c @@ -733,16 +733,20 @@ nmi_cmdline_reader_parse (const char *sysfs_dir, char **argv) { GHashTable *connections; const char *tag; - char *argument; gboolean ignore_bootif = FALSE; gboolean neednet = FALSE; - char *bootif = NULL; + gs_free char *bootif_val = NULL; int i; connections = g_hash_table_new_full (nm_str_hash, g_str_equal, g_free, g_object_unref); for (i = 0; argv[i]; i++) { - argument = argv[i]; + gs_free char *argument_clone = NULL; + char *argument; + + argument_clone = g_strdup (argv[i]); + argument = argument_clone; + tag = get_word (&argument, '='); if (strcmp (tag, "ip") == 0) parse_ip (connections, sysfs_dir, argument); @@ -768,15 +772,18 @@ nmi_cmdline_reader_parse (const char *sysfs_dir, char **argv) neednet = _nm_utils_ascii_str_to_bool (argument, TRUE); else if (strcmp (tag, "rd.znet") == 0) parse_rd_znet (connections, argument); - else if (strcasecmp (tag, "BOOTIF") == 0) - bootif = argument; + else if (strcasecmp (tag, "BOOTIF") == 0) { + nm_clear_g_free (&bootif_val); + bootif_val = g_strdup (argument); + } } if (ignore_bootif) - bootif = NULL; - if (bootif) { + nm_clear_g_free (&bootif_val); + if (bootif_val) { NMConnection *connection; NMSettingWired *s_wired; + const char *bootif = bootif_val; if ( !nm_utils_hwaddr_valid (bootif, ETH_ALEN) && g_str_has_prefix (bootif, "01-") -- cgit v1.2.1 From eea8ee23213d5e701bbff1506644de80a86c0ace Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 27 Sep 2019 08:32:08 +0200 Subject: initrd/tests: check for the parsed values in detail for rd.znet test --- src/initrd/tests/test-cmdline-reader.c | 55 +++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/src/initrd/tests/test-cmdline-reader.c b/src/initrd/tests/test-cmdline-reader.c index e06c299968..0c10bcd351 100644 --- a/src/initrd/tests/test-cmdline-reader.c +++ b/src/initrd/tests/test-cmdline-reader.c @@ -793,12 +793,59 @@ static void test_rd_znet (void) { gs_unref_hashtable GHashTable *connections = NULL; - gs_strfreev char **argv = g_strdupv ((char *[]){ "ip=10.11.12.13::10.11.12.1:24:foo.example.com:enc800:none", - "rd.znet=ctc,0.0.0800,0.0.0801,layer2=0,portno=0", NULL }); - - connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv); + const char *const*const ARGV = NM_MAKE_STRV ("ip=10.11.12.13::10.11.12.1:24:foo.example.com:enc800:none", + "rd.znet=ctc,0.0.0800,0.0.0801,layer2=0,portno=1"); + GHashTableIter h_iter; + NMConnection *connection; + NMSettingWired *s_wired; + const char *const*v_subchannels; + const NMUtilsNamedValue s390_options[] = { + { .name = "layer2", .value_str = "0" }, + { .name = "portno", .value_str = "1" }, + }; + int i_s390_options_keys; + + connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", (char **) ARGV); g_assert (connections); g_assert_cmpint (g_hash_table_size (connections), ==, 1); + + g_hash_table_iter_init (&h_iter, connections); + if (!g_hash_table_iter_next (&h_iter, NULL, (gpointer *) &connection)) + g_assert_not_reached (); + if (g_hash_table_iter_next (&h_iter, NULL, NULL)) + g_assert_not_reached (); + + g_assert (NM_IS_CONNECTION (connection)); + s_wired = nm_connection_get_setting_wired (connection); + g_assert (NM_IS_SETTING_WIRED (s_wired)); + + v_subchannels = nm_setting_wired_get_s390_subchannels (s_wired); + g_assert (v_subchannels); + g_assert_cmpstr (v_subchannels[0], ==, "0.0.0800"); + g_assert_cmpstr (v_subchannels[1], ==, "0.0.0801"); + g_assert_cmpstr (v_subchannels[2], ==, NULL); + + g_assert_cmpint (nm_setting_wired_get_num_s390_options (s_wired), ==, G_N_ELEMENTS (s390_options)); + for (i_s390_options_keys = 0; i_s390_options_keys < G_N_ELEMENTS (s390_options); i_s390_options_keys++) { + const NMUtilsNamedValue *s390_option = &s390_options[i_s390_options_keys]; + const char *k; + const char *v; + const char *v2; + + g_assert (s390_option->name); + g_assert (s390_option->value_str); + v = nm_setting_wired_get_s390_option_by_key (s_wired, s390_option->name); + g_assert (v); + g_assert_cmpstr (v, ==, s390_option->value_str); + + if (!nm_setting_wired_get_s390_option (s_wired, i_s390_options_keys, &k, &v2)) + g_assert_not_reached (); + g_assert_cmpstr (k, ==, s390_option->name); + g_assert (v == v2); + g_assert_cmpstr (v2, ==, s390_option->value_str); + } + + nmtst_assert_connection_verifies_without_normalization (connection); } NMTST_DEFINE (); -- cgit v1.2.1 From eea783d12940b131df2d866906ae6777ca8c5603 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 27 Sep 2019 08:32:08 +0200 Subject: initrd: make "argv" argument of nmi_cmdline_reader_parse() a const strv --- src/initrd/nm-initrd-generator.c | 2 +- src/initrd/nm-initrd-generator.h | 2 +- src/initrd/nmi-cmdline-reader.c | 2 +- src/initrd/tests/test-cmdline-reader.c | 95 ++++++++++++++++------------------ 4 files changed, 47 insertions(+), 54 deletions(-) diff --git a/src/initrd/nm-initrd-generator.c b/src/initrd/nm-initrd-generator.c index e613317197..fe2d8d0dc8 100644 --- a/src/initrd/nm-initrd-generator.c +++ b/src/initrd/nm-initrd-generator.c @@ -118,7 +118,7 @@ main (int argc, char *argv[]) return 1; } - connections = nmi_cmdline_reader_parse (sysfs_dir, remaining); + connections = nmi_cmdline_reader_parse (sysfs_dir, (const char *const*) remaining); g_hash_table_foreach (connections, output_conn, connections_dir); g_hash_table_destroy (connections); diff --git a/src/initrd/nm-initrd-generator.h b/src/initrd/nm-initrd-generator.h index 365d49bd5e..d8d8962298 100644 --- a/src/initrd/nm-initrd-generator.h +++ b/src/initrd/nm-initrd-generator.h @@ -29,6 +29,6 @@ gboolean nmi_ibft_update_connection_from_nic (NMConnection *connection, GHashTab NMConnection *nmi_dt_reader_parse (const char *sysfs_dir); -GHashTable *nmi_cmdline_reader_parse (const char *sysfs_dir, char **argv); +GHashTable *nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv); #endif /* __NM_INITRD_GENERATOR_H__ */ diff --git a/src/initrd/nmi-cmdline-reader.c b/src/initrd/nmi-cmdline-reader.c index 9d59b26284..205f8d0d45 100644 --- a/src/initrd/nmi-cmdline-reader.c +++ b/src/initrd/nmi-cmdline-reader.c @@ -729,7 +729,7 @@ _normalize_conn (gpointer key, gpointer value, gpointer user_data) } GHashTable * -nmi_cmdline_reader_parse (const char *sysfs_dir, char **argv) +nmi_cmdline_reader_parse (const char *sysfs_dir, const char *const*argv) { GHashTable *connections; const char *tag; diff --git a/src/initrd/tests/test-cmdline-reader.c b/src/initrd/tests/test-cmdline-reader.c index 0c10bcd351..5352f2cffe 100644 --- a/src/initrd/tests/test-cmdline-reader.c +++ b/src/initrd/tests/test-cmdline-reader.c @@ -25,14 +25,14 @@ static void test_auto (void) { gs_unref_hashtable GHashTable *connections = NULL; - gs_strfreev char **argv = g_strdupv ((char *[]){ "ip=auto", NULL }); + const char *const*ARGV = NM_MAKE_STRV ("ip=auto"); NMConnection *connection; NMSettingConnection *s_con; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv); + connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV); g_assert (connections); g_assert_cmpint (g_hash_table_size (connections), ==, 1); @@ -77,13 +77,13 @@ static void test_if_auto_with_mtu (void) { gs_unref_hashtable GHashTable *connections = NULL; - gs_strfreev char **argv = g_strdupv ((char *[]){ "ip=eth0:auto:1666", NULL }); + const char *const*ARGV = NM_MAKE_STRV ("ip=eth0:auto:1666"); NMConnection *connection; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv); + connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV); g_assert (connections); g_assert_cmpint (g_hash_table_size (connections), ==, 1); @@ -112,12 +112,12 @@ static void test_if_dhcp6 (void) { gs_unref_hashtable GHashTable *connections = NULL; - gs_strfreev char **argv = g_strdupv ((char *[]){ "ip=eth1:dhcp6", NULL }); + const char *const*ARGV = NM_MAKE_STRV ("ip=eth1:dhcp6"); NMConnection *connection; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv); + connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV); g_assert (connections); g_assert_cmpint (g_hash_table_size (connections), ==, 1); connection = g_hash_table_lookup (connections, "eth1"); @@ -141,13 +141,13 @@ static void test_if_auto_with_mtu_and_mac (void) { gs_unref_hashtable GHashTable *connections = NULL; - gs_strfreev char **argv = g_strdupv ((char *[]){ "ip=eth2:auto6:2048:00:53:ef:12:34:56", NULL }); + const char *const*ARGV = NM_MAKE_STRV ("ip=eth2:auto6:2048:00:53:ef:12:34:56"); NMConnection *connection; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; - connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv); + connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV); g_assert (connections); g_assert_cmpint (g_hash_table_size (connections), ==, 1); @@ -177,16 +177,15 @@ static void test_if_ip4_manual (void) { gs_unref_hashtable GHashTable *connections = NULL; - gs_strfreev char **argv = g_strdupv ((char *[]){ - "ip=192.0.2.2::192.0.2.1:255.255.255.0:" - "hostname0.example.com:eth3::192.0.2.53", - "ip=203.0.113.2::203.0.113.1:26:" - "hostname1.example.com:eth4", NULL }); + const char *const*ARGV = NM_MAKE_STRV ("ip=192.0.2.2::192.0.2.1:255.255.255.0:" + "hostname0.example.com:eth3::192.0.2.53", + "ip=203.0.113.2::203.0.113.1:26:" + "hostname1.example.com:eth4"); NMConnection *connection; NMSettingIPConfig *s_ip4; NMIPAddress *ip_addr; - connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv); + connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV); g_assert (connections); g_assert_cmpint (g_hash_table_size (connections), ==, 2); @@ -234,16 +233,13 @@ static void test_if_ip6_manual (void) { gs_unref_hashtable GHashTable *connections = NULL; - gs_strfreev char **argv = g_strdupv ((char *[]){ - "ip=[2001:0db8::02]/64::[2001:0db8::01]::" - "hostname0.example.com:eth4::[2001:0db8::53]", - NULL - }); + const char *const*ARGV = NM_MAKE_STRV ("ip=[2001:0db8::02]/64::[2001:0db8::01]::" + "hostname0.example.com:eth4::[2001:0db8::53]"); NMConnection *connection; NMSettingIPConfig *s_ip6; NMIPAddress *ip_addr; - connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv); + connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV); g_assert (connections); g_assert_cmpint (g_hash_table_size (connections), ==, 1); @@ -272,17 +268,16 @@ static void test_multiple (void) { gs_unref_hashtable GHashTable *connections = NULL; - gs_strfreev char **argv = g_strdupv ((char *[]){ "ip=192.0.2.2:::::eth0", - "ip=[2001:db8::2]:::::eth0", - "BOOTIF=00:53:AB:cd:02:03", - NULL }); + const char *const*ARGV = NM_MAKE_STRV ("ip=192.0.2.2:::::eth0", + "ip=[2001:db8::2]:::::eth0", + "BOOTIF=00:53:AB:cd:02:03"); NMConnection *connection; NMSettingWired *s_wired; NMSettingIPConfig *s_ip4; NMSettingIPConfig *s_ip6; NMIPAddress *ip_addr; - connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv); + connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV); g_assert (connections); g_assert_cmpint (g_hash_table_size (connections), ==, 1); @@ -318,11 +313,10 @@ static void test_some_more (void) { gs_unref_hashtable GHashTable *connections = NULL; - gs_strfreev char **argv = g_strdupv ((char *[]){ "bootdev=eth1", "hail", "nameserver=[2001:DB8:3::53]", - "satan", "nameserver=192.0.2.53", "worship", - "BOOTIF=01-00-53-AB-cd-02-03", "doom", "rd.peerdns=0", - "rd.route=[2001:DB8:3::/48]:[2001:DB8:2::1]:ens10", - NULL }); + const char *const*ARGV = NM_MAKE_STRV ("bootdev=eth1", "hail", "nameserver=[2001:DB8:3::53]", + "satan", "nameserver=192.0.2.53", "worship", + "BOOTIF=01-00-53-AB-cd-02-03", "doom", "rd.peerdns=0", + "rd.route=[2001:DB8:3::/48]:[2001:DB8:2::1]:ens10"); NMConnection *connection; NMSettingConnection *s_con; NMSettingWired *s_wired; @@ -330,7 +324,7 @@ test_some_more (void) NMSettingIPConfig *s_ip6; NMIPRoute *ip_route; - connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv); + connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV); g_assert (connections); g_assert_cmpint (g_hash_table_size (connections), ==, 2); @@ -401,9 +395,9 @@ static void test_no_bootif (void) { gs_unref_hashtable GHashTable *connections = NULL; - gs_strfreev char **argv = g_strdupv ((char *[]){ "BOOTIF=01-00-53-AB-cd-02-03", "rd.bootif=0", NULL }); + const char *const*ARGV = NM_MAKE_STRV ("BOOTIF=01-00-53-AB-cd-02-03", "rd.bootif=0"); - connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv); + connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV); g_assert (connections); g_assert_cmpint (g_hash_table_size (connections), ==, 0); } @@ -412,10 +406,9 @@ static void test_bond (void) { gs_unref_hashtable GHashTable *connections = NULL; - gs_strfreev char **argv = g_strdupv ((char *[]){ "rd.route=192.0.2.53::bong0", - "bond=bong0:eth0,eth1:mode=balance-rr", - "nameserver=203.0.113.53", - NULL }); + const char *const*ARGV = NM_MAKE_STRV ("rd.route=192.0.2.53::bong0", + "bond=bong0:eth0,eth1:mode=balance-rr", + "nameserver=203.0.113.53"); NMConnection *connection; NMSettingConnection *s_con; NMSettingIPConfig *s_ip4; @@ -424,7 +417,7 @@ test_bond (void) NMIPRoute *ip_route; const char *master_uuid; - connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv); + connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV); g_assert (connections); g_assert_cmpint (g_hash_table_size (connections), ==, 3); @@ -495,7 +488,7 @@ static void test_bond_default (void) { gs_unref_hashtable GHashTable *connections = NULL; - gs_strfreev char **argv = g_strdupv ((char *[]){ "bond", NULL }); + const char *const*ARGV = NM_MAKE_STRV ("bond"); NMConnection *connection; NMSettingConnection *s_con; NMSettingIPConfig *s_ip4; @@ -503,7 +496,7 @@ test_bond_default (void) NMSettingBond *s_bond; const char *master_uuid; - connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv); + connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV); g_assert (connections); g_assert_cmpint (g_hash_table_size (connections), ==, 2); @@ -555,7 +548,7 @@ static void test_bridge (void) { gs_unref_hashtable GHashTable *connections = NULL; - gs_strfreev char **argv = g_strdupv ((char *[]){ "bridge=bridge0:eth0,eth1", "rd.route=192.0.2.53::bridge0", NULL }); + const char *const*ARGV = NM_MAKE_STRV ("bridge=bridge0:eth0,eth1", "rd.route=192.0.2.53::bridge0"); NMConnection *connection; NMSettingConnection *s_con; NMSettingIPConfig *s_ip4; @@ -564,7 +557,7 @@ test_bridge (void) NMIPRoute *ip_route; const char *master_uuid; - connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv); + connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV); g_assert (connections); g_assert_cmpint (g_hash_table_size (connections), ==, 3); @@ -632,7 +625,7 @@ static void test_bridge_default (void) { gs_unref_hashtable GHashTable *connections = NULL; - gs_strfreev char **argv = g_strdupv ((char *[]){ "bridge", NULL }); + const char *const*ARGV = NM_MAKE_STRV ("bridge"); NMConnection *connection; NMSettingConnection *s_con; NMSettingIPConfig *s_ip4; @@ -640,7 +633,7 @@ test_bridge_default (void) NMSettingBridge *s_bridge; const char *master_uuid; - connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv); + connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV); g_assert (connections); g_assert_cmpint (g_hash_table_size (connections), ==, 2); @@ -690,7 +683,7 @@ static void test_team (void) { gs_unref_hashtable GHashTable *connections = NULL; - gs_strfreev char **argv = g_strdupv ((char *[]){ "team=team0:eth0,eth1", "ip=team0:dhcp6", NULL }); + const char *const*ARGV = NM_MAKE_STRV ("team=team0:eth0,eth1", "ip=team0:dhcp6"); NMConnection *connection; NMSettingConnection *s_con; NMSettingIPConfig *s_ip4; @@ -698,7 +691,7 @@ test_team (void) NMSettingTeam *s_team; const char *master_uuid; - connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv); + connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV); g_assert (connections); g_assert_cmpint (g_hash_table_size (connections), ==, 3); @@ -760,10 +753,10 @@ static void test_ibft (void) { gs_unref_hashtable GHashTable *connections = NULL; - gs_strfreev char **argv = g_strdupv ((char *[]){ "ip=ibft", NULL }); + const char *const*ARGV = NM_MAKE_STRV ("ip=ibft"); NMConnection *connection; - connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv); + connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV); g_assert (connections); g_assert_cmpint (g_hash_table_size (connections), ==, 2); @@ -782,9 +775,9 @@ static void test_ignore_extra (void) { gs_unref_hashtable GHashTable *connections = NULL; - gs_strfreev char **argv = g_strdupv ((char *[]){ "blabla", "extra", "lalala", NULL }); + const char *const*ARGV = NM_MAKE_STRV ("blabla", "extra", "lalala"); - connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", argv); + connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV); g_assert (connections); g_assert_cmpint (g_hash_table_size (connections), ==, 0); } @@ -805,7 +798,7 @@ test_rd_znet (void) }; int i_s390_options_keys; - connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", (char **) ARGV); + connections = nmi_cmdline_reader_parse (TEST_INITRD_DIR "/sysfs", ARGV); g_assert (connections); g_assert_cmpint (g_hash_table_size (connections), ==, 1); -- cgit v1.2.1