initrd: refactor parsing of "rd.ethtool=" to accept zero positional arguments

The point of positional arguments is that you can omit them, and that
should be treated as the parameter being set to the default.

So, don't treat "rd.ethtool=eth0" (or "rd.ethtool=eth0:") special.
Just continue the parsing and take all following positional arguments
as unset.
This commit is contained in:
Thomas Haller 2021-09-16 16:50:15 +02:00
parent 0e384b0170
commit 44e484a6aa
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 3 additions and 12 deletions

View file

@ -1187,11 +1187,6 @@ reader_parse_ethtool(Reader *reader, char *argument)
return;
}
if (!*argument) {
_LOGW(LOGD_CORE, "Could not find rd.ethtool options to set");
return;
}
autoneg_str = get_word(&argument, ':');
speed_str = get_word(&argument, ':');

View file

@ -2318,11 +2318,9 @@ test_rd_ethtool(void)
NMTST_EXPECT_NM_WARN("cmdline-reader: Impossible to set rd.ethtool options: invalid format");
_ethtool_check_inval("rd.ethtool=");
NMTST_EXPECT_NM_WARN("cmdline-reader: Could not find rd.ethtool options to set");
_ethtool_check_inval("rd.ethtool=eth0");
_ethtool_check("rd.ethtool=eth0", FALSE, 0);
NMTST_EXPECT_NM_WARN("cmdline-reader: Could not find rd.ethtool options to set");
_ethtool_check_inval("rd.ethtool=eth0:");
_ethtool_check("rd.ethtool=eth0:", FALSE, 0);
NMTST_EXPECT_NM_WARN("cmdline-reader: Impossible to set rd.ethtool options: invalid format");
_ethtool_check_inval("rd.ethtool=::");
@ -2407,9 +2405,7 @@ test_rd_ethtool(void)
_ethtool_check_v(NM_MAKE_STRV("rd.ethtool=eth0:off:100", "rd.ethtool=eth0:off"), FALSE, 0);
_ethtool_check_v(NM_MAKE_STRV("rd.ethtool=eth0:on:100", "rd.ethtool=eth0:on"), TRUE, 0);
_ethtool_check_v(NM_MAKE_STRV("rd.ethtool=eth0:on:100", "rd.ethtool=eth0:off"), FALSE, 0);
NMTST_EXPECT_NM_WARN("cmdline-reader: Could not find rd.ethtool options to set");
_ethtool_check_v(NM_MAKE_STRV("rd.ethtool=eth0:off:100", "rd.ethtool=eth0:"), FALSE, 100);
_ethtool_check_v(NM_MAKE_STRV("rd.ethtool=eth0:off:100", "rd.ethtool=eth0:"), FALSE, 0);
}
/*****************************************************************************/