initrd: reword warnings when parsing "rd.ethtool=" option

"Impossible to set rd.ethtool options: invalid format" is not very
clear. Try to explain what is invalid about the format (the interface
name is missing).

"Invalid value for rd.ethtool.autoneg, rd.ethtool.autoneg was not set"
is also confusing. The message gets printed if the autoneg value was
specified on the command line, so "was not set" seems wrong. Maybe the
message meant that the profile value is left at the default (FALSE),
but that isn't very clear.

Reword.
This commit is contained in:
Thomas Haller 2021-09-16 16:50:15 +02:00
parent 2c3f967d1a
commit abeedad315
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 20 additions and 36 deletions

View file

@ -1183,7 +1183,7 @@ reader_parse_ethtool(Reader *reader, char *argument)
interface = get_word(&argument, ':');
if (!interface) {
_LOGW(LOGD_CORE, "Impossible to set rd.ethtool options: invalid format");
_LOGW(LOGD_CORE, "rd.ethtool: interface unspecified. Ignore");
return;
}
@ -1194,15 +1194,14 @@ reader_parse_ethtool(Reader *reader, char *argument)
if (autoneg_str) {
autoneg = _nm_utils_ascii_str_to_bool(autoneg_str, -1);
if (autoneg == -1)
_LOGW(LOGD_CORE,
"Invalid value for rd.ethtool.autoneg, rd.ethtool.autoneg was not set");
_LOGW(LOGD_CORE, "rd.ethtool: autoneg invalid. Must be boolean or empty");
}
speed = 0;
if (speed_str) {
speed = _nm_utils_ascii_str_to_int64(speed_str, 10, 0, G_MAXUINT32, 0);
if (errno)
_LOGW(LOGD_CORE, "Invalid value for rd.ethtool.speed, rd.ethtool.speed was not set");
_LOGW(LOGD_CORE, "rd.ethtool: speed invalid. Must be an integer or empty");
}
if (speed == 0 && autoneg == FALSE) {
@ -1227,9 +1226,7 @@ reader_parse_ethtool(Reader *reader, char *argument)
}
if (*argument)
_LOGW(LOGD_CORE,
"Invalid extra argument '%s' for rd.ethtool, this value was not set",
argument);
_LOGW(LOGD_CORE, "rd.ethtool: extra argument ignored");
}
static void

View file

@ -2315,14 +2315,14 @@ test_carrier_timeout(void)
static void
test_rd_ethtool(void)
{
NMTST_EXPECT_NM_WARN("cmdline-reader: Impossible to set rd.ethtool options: invalid format");
NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: interface unspecified. Ignore");
_ethtool_check_inval("rd.ethtool=");
_ethtool_check("rd.ethtool=eth0", FALSE, 0);
_ethtool_check("rd.ethtool=eth0:", FALSE, 0);
NMTST_EXPECT_NM_WARN("cmdline-reader: Impossible to set rd.ethtool options: invalid format");
NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: interface unspecified. Ignore");
_ethtool_check_inval("rd.ethtool=::");
_ethtool_check("rd.ethtool=eth0:on", TRUE, 0);
@ -2346,61 +2346,48 @@ test_rd_ethtool(void)
"without setting speed");
_ethtool_check("rd.ethtool=eth0:0", FALSE, 0);
NMTST_EXPECT_NM_WARN(
"cmdline-reader: Invalid value for rd.ethtool.autoneg, rd.ethtool.autoneg was not set");
NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: autoneg invalid. Must be boolean or empty");
_ethtool_check("rd.ethtool=eth0:randomstring", FALSE, 0);
_ethtool_check("rd.ethtool=eth0::", FALSE, 0);
NMTST_EXPECT_NM_WARN(
"cmdline-reader: Invalid value for rd.ethtool.speed, rd.ethtool.speed was not set");
NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: speed invalid. Must be an integer or empty");
_ethtool_check("rd.ethtool=eth0::astring", FALSE, 0);
NMTST_EXPECT_NM_WARN(
"cmdline-reader: Invalid value for rd.ethtool.speed, rd.ethtool.speed was not set");
NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: speed invalid. Must be an integer or empty");
_ethtool_check("rd.ethtool=eth0::1000000000000000000000000000000000000", FALSE, 0);
NMTST_EXPECT_NM_WARN(
"cmdline-reader: Invalid value for rd.ethtool.speed, rd.ethtool.speed was not set");
NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: speed invalid. Must be an integer or empty");
_ethtool_check("rd.ethtool=eth0::0.67", FALSE, 0);
NMTST_EXPECT_NM_WARN(
"cmdline-reader: Invalid value for rd.ethtool.speed, rd.ethtool.speed was not set");
NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: speed invalid. Must be an integer or empty");
_ethtool_check("rd.ethtool=eth0::-23", FALSE, 0);
NMTST_EXPECT_NM_WARN(
"cmdline-reader: Invalid value for rd.ethtool.speed, rd.ethtool.speed was not set");
NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: speed invalid. Must be an integer or empty");
_ethtool_check("rd.ethtool=eth0::-23:", FALSE, 0);
NMTST_EXPECT_NM_WARN(
"cmdline-reader: Invalid value for rd.ethtool.speed, rd.ethtool.speed was not set");
NMTST_EXPECT_NM_WARN(
"cmdline-reader: Invalid extra argument ':' for rd.ethtool, this value was not set");
NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: speed invalid. Must be an integer or empty");
NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: extra argument ignored");
_ethtool_check("rd.ethtool=eth0::-23::", FALSE, 0);
NMTST_EXPECT_NM_WARN(
"cmdline-reader: Invalid value for rd.ethtool.speed, rd.ethtool.speed was not set");
NMTST_EXPECT_NM_WARN(
"cmdline-reader: Invalid extra argument ':foo' for rd.ethtool, this value was not set");
NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: speed invalid. Must be an integer or empty");
NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: extra argument ignored");
_ethtool_check("rd.ethtool=eth0::-23::foo", FALSE, 0);
_ethtool_check("rd.ethtool=eth0:1:10", TRUE, 10);
_ethtool_check("rd.ethtool=eth0::100", FALSE, 100);
NMTST_EXPECT_NM_WARN(
"cmdline-reader: Invalid extra argument 'bogus' for rd.ethtool, this value was not set");
NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: extra argument ignored");
_ethtool_check("rd.ethtool=eth0:::bogus", FALSE, 0);
NMTST_EXPECT_NM_WARN(
"cmdline-reader: Invalid extra argument 'bogus' for rd.ethtool, this value was not set");
NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: extra argument ignored");
_ethtool_check("rd.ethtool=eth0::10:bogus", FALSE, 10);
NMTST_EXPECT_NM_WARN(
"cmdline-reader: Invalid extra argument 'bogus' for rd.ethtool, this value was not set");
NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: extra argument ignored");
_ethtool_check("rd.ethtool=eth0:on:100:bogus", TRUE, 100);
NMTST_EXPECT_NM_WARN("cmdline-reader: Impossible to set rd.ethtool options: invalid format");
NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: interface unspecified. Ignore");
_ethtool_check_inval("rd.ethtool=:::");
NMTST_EXPECT_NM_WARN("cmdline-reader: rd.ethtool: autoneg ignored. Cannot disable autoneg "