1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-13 17:18:18 +03:00

network: drop no-op cleanup

- network_load() is always called with an empty OrderedHashmap, renamed the output
  parameter to 'ret'.
- When netdev_load() is called on startup, the hashmap is NULL. When it is
  called on reloading, the hashmap is not cleaned up.

Hence, then these cleanups are always no-op. Let's drop them.
This commit is contained in:
Yu Watanabe 2024-10-27 16:29:24 +09:00
parent d16083557b
commit 173c9f639b
5 changed files with 10 additions and 12 deletions

View File

@ -1014,15 +1014,12 @@ int netdev_load_one(Manager *manager, const char *filename) {
return 0;
}
int netdev_load(Manager *manager, bool reload) {
int netdev_load(Manager *manager) {
_cleanup_strv_free_ char **files = NULL;
int r;
assert(manager);
if (!reload)
hashmap_clear_with_destructor(manager->netdevs, netdev_unref);
r = conf_files_list_strv(&files, ".netdev", NULL, 0, NETWORK_DIRS);
if (r < 0)
return log_error_errno(r, "Failed to enumerate netdev files: %m");

View File

@ -211,7 +211,7 @@ NetDev* netdev_detach_name(NetDev *netdev, const char *name);
void netdev_detach(NetDev *netdev);
int netdev_set_ifindex_internal(NetDev *netdev, int ifindex);
int netdev_load(Manager *manager, bool reload);
int netdev_load(Manager *manager);
int netdev_load_one(Manager *manager, const char *filename);
void netdev_drop(NetDev *netdev);
void netdev_enter_failed(NetDev *netdev);

View File

@ -739,7 +739,7 @@ int manager_start(Manager *m) {
int manager_load_config(Manager *m) {
int r;
r = netdev_load(m, false);
r = netdev_load(m);
if (r < 0)
return r;
@ -1150,7 +1150,7 @@ int manager_reload(Manager *m, sd_bus_message *message) {
(void) notify_reloading();
r = netdev_load(m, /* reload= */ true);
r = netdev_load(m);
if (r < 0)
goto finish;

View File

@ -598,21 +598,22 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
return 0;
}
int network_load(Manager *manager, OrderedHashmap **networks) {
int network_load(Manager *manager, OrderedHashmap **ret) {
_cleanup_strv_free_ char **files = NULL;
OrderedHashmap *networks = NULL;
int r;
assert(manager);
ordered_hashmap_clear_with_destructor(*networks, network_unref);
assert(ret);
r = conf_files_list_strv(&files, ".network", NULL, 0, NETWORK_DIRS);
if (r < 0)
return log_error_errno(r, "Failed to enumerate network files: %m");
STRV_FOREACH(f, files)
(void) network_load_one(manager, networks, *f);
(void) network_load_one(manager, &networks, *f);
*ret = TAKE_PTR(networks);
return 0;
}

View File

@ -419,7 +419,7 @@ Network *network_ref(Network *network);
Network *network_unref(Network *network);
DEFINE_TRIVIAL_CLEANUP_FUNC(Network*, network_unref);
int network_load(Manager *manager, OrderedHashmap **networks);
int network_load(Manager *manager, OrderedHashmap **ret);
int network_reload(Manager *manager);
int network_load_one(Manager *manager, OrderedHashmap **networks, const char *filename);
int network_verify(Network *network);