summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2014-08-22 10:35:59 +0200
committerMichal Schmidt <mschmidt@redhat.com>2014-10-23 17:38:02 +0200
commit9f03ee51a2207954ef18be79ca3e11cd14ca56fd (patch)
tree550b291500f9e99937bf854c53e1d17ba73472ac /src/shared
parentdd0124f6cb6ff7da1ce8be23ec7e1137fe15958d (diff)
install: make InstallContext::{will_install,have_installed} OrderedHashmaps
It appears order may matter here. Use OrderedHashmaps to be safe.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/install.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/shared/install.c b/src/shared/install.c
index ff5dcbac15..4ef7dc8d98 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -41,8 +41,8 @@
#include "special.h"
typedef struct {
- Hashmap *will_install;
- Hashmap *have_installed;
+ OrderedHashmap *will_install;
+ OrderedHashmap *have_installed;
} InstallContext;
static int in_search_path(const char *path, char **search) {
@@ -844,16 +844,16 @@ static void install_info_free(InstallInfo *i) {
free(i);
}
-static void install_info_hashmap_free(Hashmap *m) {
+static void install_info_hashmap_free(OrderedHashmap *m) {
InstallInfo *i;
if (!m)
return;
- while ((i = hashmap_steal_first(m)))
+ while ((i = ordered_hashmap_steal_first(m)))
install_info_free(i);
- hashmap_free(m);
+ ordered_hashmap_free(m);
}
static void install_context_done(InstallContext *c) {
@@ -881,11 +881,11 @@ static int install_info_add(
if (!unit_name_is_valid(name, TEMPLATE_VALID))
return -EINVAL;
- if (hashmap_get(c->have_installed, name) ||
- hashmap_get(c->will_install, name))
+ if (ordered_hashmap_get(c->have_installed, name) ||
+ ordered_hashmap_get(c->will_install, name))
return 0;
- r = hashmap_ensure_allocated(&c->will_install, &string_hash_ops);
+ r = ordered_hashmap_ensure_allocated(&c->will_install, &string_hash_ops);
if (r < 0)
return r;
@@ -907,7 +907,7 @@ static int install_info_add(
}
}
- r = hashmap_put(c->will_install, i->name, i);
+ r = ordered_hashmap_put(c->will_install, i->name, i);
if (r < 0)
goto fail;
@@ -1180,7 +1180,7 @@ static int unit_file_can_install(
if (r < 0)
return r;
- assert_se(i = hashmap_first(c.will_install));
+ assert_se(i = ordered_hashmap_first(c.will_install));
r = unit_file_search(&c, i, paths, root_dir, allow_symlink, true);
@@ -1401,13 +1401,13 @@ static int install_context_apply(
assert(paths);
assert(config_path);
- while ((i = hashmap_first(c->will_install))) {
+ while ((i = ordered_hashmap_first(c->will_install))) {
- q = hashmap_ensure_allocated(&c->have_installed, &string_hash_ops);
+ q = ordered_hashmap_ensure_allocated(&c->have_installed, &string_hash_ops);
if (q < 0)
return q;
- assert_se(hashmap_move_one(c->have_installed, c->will_install, i->name) == 0);
+ assert_se(ordered_hashmap_move_one(c->have_installed, c->will_install, i->name) == 0);
q = unit_file_search(c, i, paths, root_dir, false, true);
if (q < 0) {
@@ -1442,13 +1442,13 @@ static int install_context_mark_for_removal(
/* Marks all items for removal */
- while ((i = hashmap_first(c->will_install))) {
+ while ((i = ordered_hashmap_first(c->will_install))) {
- q = hashmap_ensure_allocated(&c->have_installed, &string_hash_ops);
+ q = ordered_hashmap_ensure_allocated(&c->have_installed, &string_hash_ops);
if (q < 0)
return q;
- assert_se(hashmap_move_one(c->have_installed, c->will_install, i->name) == 0);
+ assert_se(ordered_hashmap_move_one(c->have_installed, c->will_install, i->name) == 0);
q = unit_file_search(c, i, paths, root_dir, false, true);
if (q == -ENOENT) {
@@ -1544,12 +1544,12 @@ int unit_file_add_dependency(
return r;
}
- while ((info = hashmap_first(c.will_install))) {
- r = hashmap_ensure_allocated(&c.have_installed, &string_hash_ops);
+ while ((info = ordered_hashmap_first(c.will_install))) {
+ r = ordered_hashmap_ensure_allocated(&c.have_installed, &string_hash_ops);
if (r < 0)
return r;
- assert_se(hashmap_move_one(c.have_installed, c.will_install, info->name) == 0);
+ assert_se(ordered_hashmap_move_one(c.have_installed, c.will_install, info->name) == 0);
r = unit_file_search(&c, info, &paths, root_dir, false, false);
if (r < 0)
@@ -1720,7 +1720,7 @@ int unit_file_set_default(
if (r < 0)
return r;
- assert_se(i = hashmap_first(c.will_install));
+ assert_se(i = ordered_hashmap_first(c.will_install));
r = unit_file_search(&c, i, &paths, root_dir, false, true);
if (r < 0)