tree-wide: use path_hash_ops instead of string_hash_ops whenever we key by a path
Let's make use of our new hash_ops!
This commit is contained in:
parent
46e16b347f
commit
548f69375e
|
@ -426,7 +426,7 @@ int bind_remount_recursive_with_mountinfo(const char *prefix, bool ro, char **bl
|
|||
|
||||
path_kill_slashes(cleaned);
|
||||
|
||||
done = set_new(&string_hash_ops);
|
||||
done = set_new(&path_hash_ops);
|
||||
if (!done)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -436,7 +436,7 @@ int bind_remount_recursive_with_mountinfo(const char *prefix, bool ro, char **bl
|
|||
char *x;
|
||||
unsigned long orig_flags;
|
||||
|
||||
todo = set_new(&string_hash_ops);
|
||||
todo = set_new(&path_hash_ops);
|
||||
if (!todo)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -928,8 +928,8 @@ int main(int argc, char *argv[]) {
|
|||
} else
|
||||
log_debug("Cgroup path: %s", root);
|
||||
|
||||
a = hashmap_new(&string_hash_ops);
|
||||
b = hashmap_new(&string_hash_ops);
|
||||
a = hashmap_new(&path_hash_ops);
|
||||
b = hashmap_new(&path_hash_ops);
|
||||
if (!a || !b) {
|
||||
r = log_oom();
|
||||
goto finish;
|
||||
|
|
|
@ -77,7 +77,7 @@ static int device_set_sysfs(Device *d, const char *sysfs) {
|
|||
if (streq_ptr(d->sysfs, sysfs))
|
||||
return 0;
|
||||
|
||||
r = hashmap_ensure_allocated(&UNIT(d)->manager->devices_by_sysfs, &string_hash_ops);
|
||||
r = hashmap_ensure_allocated(&UNIT(d)->manager->devices_by_sysfs, &path_hash_ops);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
|
|
@ -731,7 +731,7 @@ int manager_new(UnitFileScope scope, unsigned test_run_flags, Manager **_m) {
|
|||
if (r < 0)
|
||||
goto fail;
|
||||
|
||||
r = hashmap_ensure_allocated(&m->cgroup_unit, &string_hash_ops);
|
||||
r = hashmap_ensure_allocated(&m->cgroup_unit, &path_hash_ops);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
|
||||
|
@ -1314,7 +1314,7 @@ static void manager_build_unit_path_cache(Manager *m) {
|
|||
|
||||
set_free_free(m->unit_path_cache);
|
||||
|
||||
m->unit_path_cache = set_new(&string_hash_ops);
|
||||
m->unit_path_cache = set_new(&path_hash_ops);
|
||||
if (!m->unit_path_cache) {
|
||||
r = -ENOMEM;
|
||||
goto fail;
|
||||
|
|
|
@ -1837,7 +1837,7 @@ static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents,
|
|||
mount->parameters_proc_self_mountinfo.what) {
|
||||
|
||||
/* Remember that this device might just have disappeared */
|
||||
if (set_ensure_allocated(&gone, &string_hash_ops) < 0 ||
|
||||
if (set_ensure_allocated(&gone, &path_hash_ops) < 0 ||
|
||||
set_put(gone, mount->parameters_proc_self_mountinfo.what) < 0)
|
||||
log_oom(); /* we don't care too much about OOM here... */
|
||||
}
|
||||
|
@ -1892,7 +1892,7 @@ static int mount_dispatch_io(sd_event_source *source, int fd, uint32_t revents,
|
|||
mount->from_proc_self_mountinfo &&
|
||||
mount->parameters_proc_self_mountinfo.what) {
|
||||
|
||||
if (set_ensure_allocated(&around, &string_hash_ops) < 0 ||
|
||||
if (set_ensure_allocated(&around, &path_hash_ops) < 0 ||
|
||||
set_put(around, mount->parameters_proc_self_mountinfo.what) < 0)
|
||||
log_oom();
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ static int swap_set_devnode(Swap *s, const char *devnode) {
|
|||
|
||||
assert(s);
|
||||
|
||||
r = hashmap_ensure_allocated(&UNIT(s)->manager->swaps_by_devnode, &string_hash_ops);
|
||||
r = hashmap_ensure_allocated(&UNIT(s)->manager->swaps_by_devnode, &path_hash_ops);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
|
|
@ -4594,7 +4594,7 @@ int unit_require_mounts_for(Unit *u, const char *path, UnitDependencyMask mask)
|
|||
if (!path_is_absolute(path))
|
||||
return -EINVAL;
|
||||
|
||||
r = hashmap_ensure_allocated(&u->requires_mounts_for, &string_hash_ops);
|
||||
r = hashmap_ensure_allocated(&u->requires_mounts_for, &path_hash_ops);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
@ -4631,7 +4631,7 @@ int unit_require_mounts_for(Unit *u, const char *path, UnitDependencyMask mask)
|
|||
if (!x) {
|
||||
char *q;
|
||||
|
||||
r = hashmap_ensure_allocated(&u->manager->units_requiring_mounts_for, &string_hash_ops);
|
||||
r = hashmap_ensure_allocated(&u->manager->units_requiring_mounts_for, &path_hash_ops);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
|
|
@ -1733,12 +1733,12 @@ static sd_journal *journal_new(int flags, const char *path) {
|
|||
j->path = t;
|
||||
}
|
||||
|
||||
j->files = ordered_hashmap_new(&string_hash_ops);
|
||||
j->files = ordered_hashmap_new(&path_hash_ops);
|
||||
if (!j->files)
|
||||
goto fail;
|
||||
|
||||
j->files_cache = ordered_hashmap_iterated_cache_new(j->files);
|
||||
j->directories_by_path = hashmap_new(&string_hash_ops);
|
||||
j->directories_by_path = hashmap_new(&path_hash_ops);
|
||||
j->mmap = mmap_cache_new();
|
||||
if (!j->files_cache || !j->directories_by_path || !j->mmap)
|
||||
goto fail;
|
||||
|
|
|
@ -192,7 +192,7 @@ int devnode_acl_all(struct udev *udev,
|
|||
|
||||
assert(udev);
|
||||
|
||||
nodes = set_new(&string_hash_ops);
|
||||
nodes = set_new(&path_hash_ops);
|
||||
if (!nodes)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -2369,7 +2369,7 @@ int unit_show_processes(
|
|||
if (r < 0)
|
||||
return r;
|
||||
|
||||
cgroups = hashmap_new(&string_hash_ops);
|
||||
cgroups = hashmap_new(&path_hash_ops);
|
||||
if (!cgroups)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -522,7 +522,7 @@ static int mark_symlink_for_removal(
|
|||
|
||||
assert(p);
|
||||
|
||||
r = set_ensure_allocated(remove_symlinks_to, &string_hash_ops);
|
||||
r = set_ensure_allocated(remove_symlinks_to, &path_hash_ops);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
|
|
|
@ -110,19 +110,19 @@ static int parse_file(OrderedHashmap *sysctl_options, const char *path, bool ign
|
|||
_cleanup_free_ char *l = NULL;
|
||||
void *v;
|
||||
int k;
|
||||
|
||||
k = read_line(f, LONG_LINE_MAX, &l);
|
||||
if (k == 0)
|
||||
break;
|
||||
|
||||
if (k < 0)
|
||||
return log_error_errno(k, "Failed to read file '%s', ignoring: %m", path);
|
||||
|
||||
c++;
|
||||
|
||||
p = strstrip(l);
|
||||
if (!*p)
|
||||
continue;
|
||||
|
||||
if (isempty(p))
|
||||
continue;
|
||||
if (strchr(COMMENTS "\n", *p))
|
||||
continue;
|
||||
|
||||
|
@ -261,7 +261,7 @@ int main(int argc, char *argv[]) {
|
|||
|
||||
umask(0022);
|
||||
|
||||
sysctl_options = ordered_hashmap_new(&string_hash_ops);
|
||||
sysctl_options = ordered_hashmap_new(&path_hash_ops);
|
||||
if (!sysctl_options) {
|
||||
r = log_oom();
|
||||
goto finish;
|
||||
|
|
|
@ -383,9 +383,11 @@ static void load_unix_sockets(void) {
|
|||
|
||||
/* We maintain a cache of the sockets we found in /proc/net/unix to speed things up a little. */
|
||||
|
||||
unix_sockets = set_new(&string_hash_ops);
|
||||
if (!unix_sockets)
|
||||
unix_sockets = set_new(&path_hash_ops);
|
||||
if (!unix_sockets) {
|
||||
log_oom();
|
||||
return;
|
||||
}
|
||||
|
||||
f = fopen("/proc/net/unix", "re");
|
||||
if (!f) {
|
||||
|
|
Loading…
Reference in a new issue