mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-30 03:50:10 +01:00
initrd: make "argv" argument of nmi_cmdline_reader_parse() a const strv
This commit is contained in:
parent
eea8ee2321
commit
eea783d129
4 changed files with 47 additions and 54 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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__ */
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue