mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-26 08:50:07 +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.
This commit is contained in:
parent
9b3d37721b
commit
19604cb126
1 changed files with 14 additions and 7 deletions
|
|
@ -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-")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue