mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
Merge pull request #30567 from yuwata/hashmap_isempty
tree-wide: use hashmap_isempty() and friends
This commit is contained in:
@@ -1804,7 +1804,7 @@ static void manager_distribute_fds(Manager *m, FDSet *fds) {
|
||||
|
||||
HASHMAP_FOREACH(u, m->units) {
|
||||
|
||||
if (fdset_size(fds) <= 0)
|
||||
if (fdset_isempty(fds))
|
||||
break;
|
||||
|
||||
if (!UNIT_VTABLE(u)->distribute_fds)
|
||||
@@ -2745,7 +2745,7 @@ static int manager_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t
|
||||
if (!found)
|
||||
log_warning("Cannot find unit for notify message of PID "PID_FMT", ignoring.", ucred->pid);
|
||||
|
||||
if (fdset_size(fds) > 0)
|
||||
if (!fdset_isempty(fds))
|
||||
log_warning("Got extra auxiliary fds with notification message, closing them.");
|
||||
|
||||
return 0;
|
||||
@@ -3810,7 +3810,7 @@ void manager_check_finished(Manager *m) {
|
||||
|
||||
manager_check_basic_target(m);
|
||||
|
||||
if (hashmap_size(m->jobs) > 0) {
|
||||
if (!hashmap_isempty(m->jobs)) {
|
||||
if (m->jobs_in_progress_event_source)
|
||||
/* Ignore any failure, this is only for feedback */
|
||||
(void) sd_event_source_set_time(m->jobs_in_progress_event_source,
|
||||
@@ -4545,7 +4545,7 @@ ManagerState manager_state(Manager *m) {
|
||||
}
|
||||
|
||||
/* Are there any failed units? If so, we are in degraded mode */
|
||||
if (set_size(m->failed_units) > 0)
|
||||
if (!set_isempty(m->failed_units))
|
||||
return MANAGER_DEGRADED;
|
||||
|
||||
return MANAGER_RUNNING;
|
||||
|
||||
@@ -650,8 +650,8 @@ void client_context_flush_all(Server *s) {
|
||||
|
||||
client_context_flush_regular(s);
|
||||
|
||||
assert(prioq_size(s->client_contexts_lru) == 0);
|
||||
assert(hashmap_size(s->client_contexts) == 0);
|
||||
assert(prioq_isempty(s->client_contexts_lru));
|
||||
assert(hashmap_isempty(s->client_contexts));
|
||||
|
||||
s->client_contexts_lru = prioq_free(s->client_contexts_lru);
|
||||
s->client_contexts = hashmap_free(s->client_contexts);
|
||||
|
||||
@@ -2633,7 +2633,7 @@ int server_init(Server *s, const char *namespace) {
|
||||
/* Try to restore streams, but don't bother if this fails */
|
||||
(void) server_restore_streams(s, fds);
|
||||
|
||||
if (fdset_size(fds) > 0) {
|
||||
if (!fdset_isempty(fds)) {
|
||||
log_warning("%u unknown file descriptors passed, closing.", fdset_size(fds));
|
||||
fds = fdset_free(fds);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ static void bus_track_add_to_queue(sd_bus_track *track) {
|
||||
return;
|
||||
|
||||
/* still referenced? */
|
||||
if (hashmap_size(track->names) > 0)
|
||||
if (!hashmap_isempty(track->names))
|
||||
return;
|
||||
|
||||
/* Nothing to call? */
|
||||
|
||||
@@ -452,11 +452,12 @@ int catalog_update(const char* database, const char* root, const char* const* di
|
||||
return log_error_errno(r, "Failed to import file '%s': %m", *f);
|
||||
}
|
||||
|
||||
if (ordered_hashmap_size(h) <= 0) {
|
||||
if (ordered_hashmap_isempty(h)) {
|
||||
log_info("No items in catalog.");
|
||||
return 0;
|
||||
} else
|
||||
log_debug("Found %u items in catalog.", ordered_hashmap_size(h));
|
||||
}
|
||||
|
||||
log_debug("Found %u items in catalog.", ordered_hashmap_size(h));
|
||||
|
||||
items = new(CatalogItem, ordered_hashmap_size(h));
|
||||
if (!items)
|
||||
|
||||
@@ -932,8 +932,8 @@ static int real_journal_next(sd_journal *j, direction_t direction) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
for (unsigned i = 0; i < n_files; i++) {
|
||||
JournalFile *f = (JournalFile *)files[i];
|
||||
FOREACH_ARRAY(_f, files, n_files) {
|
||||
JournalFile *f = (JournalFile*) *_f;
|
||||
bool found;
|
||||
|
||||
r = next_beyond_location(j, f, direction);
|
||||
|
||||
@@ -176,7 +176,7 @@ static int dispatch_rqueue(sd_netlink *nl, sd_netlink_message **ret) {
|
||||
assert(nl);
|
||||
assert(ret);
|
||||
|
||||
if (ordered_set_size(nl->rqueue) <= 0) {
|
||||
if (ordered_set_isempty(nl->rqueue)) {
|
||||
/* Try to read a new message */
|
||||
r = socket_read_message(nl);
|
||||
if (r == -ENOBUFS) /* FIXME: ignore buffer overruns for now */
|
||||
@@ -443,7 +443,7 @@ int sd_netlink_wait(sd_netlink *nl, uint64_t timeout_usec) {
|
||||
assert_return(nl, -EINVAL);
|
||||
assert_return(!netlink_pid_changed(nl), -ECHILD);
|
||||
|
||||
if (ordered_set_size(nl->rqueue) > 0)
|
||||
if (!ordered_set_isempty(nl->rqueue))
|
||||
return 0;
|
||||
|
||||
r = netlink_poll(nl, false, timeout_usec);
|
||||
@@ -623,7 +623,7 @@ int sd_netlink_get_events(sd_netlink *nl) {
|
||||
assert_return(nl, -EINVAL);
|
||||
assert_return(!netlink_pid_changed(nl), -ECHILD);
|
||||
|
||||
return ordered_set_size(nl->rqueue) == 0 ? POLLIN : 0;
|
||||
return ordered_set_isempty(nl->rqueue) ? POLLIN : 0;
|
||||
}
|
||||
|
||||
int sd_netlink_get_timeout(sd_netlink *nl, uint64_t *timeout_usec) {
|
||||
@@ -633,7 +633,7 @@ int sd_netlink_get_timeout(sd_netlink *nl, uint64_t *timeout_usec) {
|
||||
assert_return(timeout_usec, -EINVAL);
|
||||
assert_return(!netlink_pid_changed(nl), -ECHILD);
|
||||
|
||||
if (ordered_set_size(nl->rqueue) > 0) {
|
||||
if (!ordered_set_isempty(nl->rqueue)) {
|
||||
*timeout_usec = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -3394,7 +3394,7 @@ static int inner_child(
|
||||
if (asprintf(envp + n_env++, "container_uuid=%s", SD_ID128_TO_UUID_STRING(arg_uuid)) < 0)
|
||||
return log_oom();
|
||||
|
||||
if (fdset_size(fds) > 0) {
|
||||
if (!fdset_isempty(fds)) {
|
||||
r = fdset_cloexec(fds, false);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to unset O_CLOEXEC for file descriptors.");
|
||||
|
||||
@@ -276,7 +276,7 @@ int oomd_cgroup_kill(const char *path, bool recurse, bool dry_run) {
|
||||
if (r < 0)
|
||||
log_debug_errno(r, "Failed to set user.oomd_kill on kill: %m");
|
||||
|
||||
return set_size(pids_killed) != 0;
|
||||
return !set_isempty(pids_killed);
|
||||
}
|
||||
|
||||
typedef void (*dump_candidate_func)(const OomdCGroupContext *ctx, FILE *f, const char *prefix);
|
||||
|
||||
@@ -164,8 +164,8 @@ void dns_cache_flush(DnsCache *c) {
|
||||
while ((key = hashmap_first_key(c->by_key)))
|
||||
dns_cache_remove_by_key(c, key);
|
||||
|
||||
assert(hashmap_size(c->by_key) == 0);
|
||||
assert(prioq_size(c->by_expiry) == 0);
|
||||
assert(hashmap_isempty(c->by_key));
|
||||
assert(prioq_isempty(c->by_expiry));
|
||||
|
||||
c->by_key = hashmap_free(c->by_key);
|
||||
c->by_expiry = prioq_free(c->by_expiry);
|
||||
@@ -186,7 +186,7 @@ static void dns_cache_make_space(DnsCache *c, unsigned add) {
|
||||
_cleanup_(dns_resource_key_unrefp) DnsResourceKey *key = NULL;
|
||||
DnsCacheItem *i;
|
||||
|
||||
if (prioq_size(c->by_expiry) <= 0)
|
||||
if (prioq_isempty(c->by_expiry))
|
||||
break;
|
||||
|
||||
if (prioq_size(c->by_expiry) + add < CACHE_MAX)
|
||||
|
||||
@@ -1557,7 +1557,7 @@ int dns_scope_add_dnssd_services(DnsScope *scope) {
|
||||
|
||||
assert(scope);
|
||||
|
||||
if (hashmap_size(scope->manager->dnssd_services) == 0)
|
||||
if (hashmap_isempty(scope->manager->dnssd_services))
|
||||
return 0;
|
||||
|
||||
scope->announced = false;
|
||||
|
||||
@@ -181,7 +181,7 @@ static int dns_trust_anchor_add_builtin_negative(DnsTrustAnchor *d) {
|
||||
* trust anchor defined at all. This enables easy overriding
|
||||
* of negative trust anchors. */
|
||||
|
||||
if (set_size(d->negative_by_name) > 0)
|
||||
if (!set_isempty(d->negative_by_name))
|
||||
return 0;
|
||||
|
||||
r = set_ensure_allocated(&d->negative_by_name, &dns_name_hash_ops);
|
||||
|
||||
@@ -70,8 +70,8 @@ void dns_zone_flush(DnsZone *z) {
|
||||
while ((i = hashmap_first(z->by_key)))
|
||||
dns_zone_item_remove_and_free(z, i);
|
||||
|
||||
assert(hashmap_size(z->by_key) == 0);
|
||||
assert(hashmap_size(z->by_name) == 0);
|
||||
assert(hashmap_isempty(z->by_key));
|
||||
assert(hashmap_isempty(z->by_name));
|
||||
|
||||
z->by_key = hashmap_free(z->by_key);
|
||||
z->by_name = hashmap_free(z->by_name);
|
||||
|
||||
@@ -747,7 +747,7 @@ static int remove_marked_symlinks(
|
||||
assert(config_path);
|
||||
assert(lp);
|
||||
|
||||
if (set_size(remove_symlinks_to) <= 0)
|
||||
if (set_isempty(remove_symlinks_to))
|
||||
return 0;
|
||||
|
||||
fd = open(config_path, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC);
|
||||
|
||||
Reference in New Issue
Block a user