mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-07 16:00:21 +01:00
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.
(cherry picked from commit 19604cb126)
This commit is contained in:
parent
83d4fb9f4e
commit
2fbd309334
1 changed files with 14 additions and 7 deletions
|
|
@ -739,16 +739,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);
|
||||
|
|
@ -774,15 +778,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-")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue