]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ethtool-util: make wol_options_to_string() not return all flag strings
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 5 Oct 2021 05:59:26 +0000 (14:59 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 6 Oct 2021 12:33:06 +0000 (21:33 +0900)
src/shared/ethtool-util.c
src/udev/net/link-config.c

index 00060abff40f6fc458a0c78d94c2ff48909008b4..0b5f64c1a33335c06db29060ef3e0239540643fe 100644 (file)
@@ -43,6 +43,11 @@ int wol_options_to_string_alloc(uint32_t opts, char **ret) {
 
         assert(ret);
 
+        if (opts == UINT32_MAX) {
+                *ret = NULL;
+                return 0;
+        }
+
         for (size_t i = 0; i < ELEMENTSOF(wol_option_map); i++)
                 if (opts & wol_option_map[i].opt &&
                     !strextend_with_separator(&str, ",", wol_option_map[i].name))
@@ -55,7 +60,7 @@ int wol_options_to_string_alloc(uint32_t opts, char **ret) {
         }
 
         *ret = TAKE_PTR(str);
-        return 0;
+        return 1;
 }
 
 static const char* const port_table[] = {
index 14ca2e032e610c038155c4003e5b452a56696726..ca0522c3042cde6f04dc69ac2f0a471c367ddc09 100644 (file)
@@ -334,8 +334,8 @@ static int link_config_apply_ethtool_settings(int *ethtool_fd, const LinkConfig
                 _cleanup_free_ char *str = NULL;
 
                 (void) wol_options_to_string_alloc(config->wol, &str);
-                log_device_warning_errno(device, r, "Could not set WakeOnLan to %s, ignoring: %m",
-                                         strna(str));
+                log_device_warning_errno(device, r, "Could not set WakeOnLan%s%s, ignoring: %m",
+                                         isempty(str) ? "" : " to ", strempty(str));
         }
 
         r = ethtool_set_features(ethtool_fd, name, config->features);