Skip to content

Commit 1bd18aa

Browse files
committed
Refactor: various: Use bool/const in pcmk__rsc_methods_t:active()
Signed-off-by: Reid Wahl <[email protected]>
1 parent 55516da commit 1bd18aa

File tree

9 files changed

+32
-33
lines changed

9 files changed

+32
-33
lines changed

include/crm/common/resources_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ typedef struct {
212212
*
213213
* \return TRUE if \p rsc is active, otherwise FALSE
214214
*/
215-
gboolean (*active)(pcmk_resource_t *rsc, gboolean all);
215+
bool (*active)(const pcmk_resource_t *rsc, bool all);
216216

217217
/*!
218218
* \internal

include/crm/pengine/internal.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ bool pe__unpack_bundle(pcmk_resource_t *rsc);
7171
pcmk_resource_t *native_find_rsc(pcmk_resource_t *rsc, const char *id,
7272
const pcmk_node_t *node, uint32_t flags);
7373

74-
gboolean native_active(pcmk_resource_t *rsc, gboolean all);
75-
gboolean group_active(pcmk_resource_t *rsc, gboolean all);
76-
gboolean clone_active(pcmk_resource_t *rsc, gboolean all);
77-
gboolean pe__bundle_active(pcmk_resource_t *rsc, gboolean all);
74+
bool native_active(const pcmk_resource_t *rsc, bool all);
75+
bool group_active(const pcmk_resource_t *rsc, bool all);
76+
bool clone_active(const pcmk_resource_t *rsc, bool all);
77+
bool pe__bundle_active(const pcmk_resource_t *rsc, bool all);
7878

7979
gchar *pcmk__native_output_string(const pcmk_resource_t *rsc, const char *name,
8080
const pcmk_node_t *node, uint32_t show_opts,

lib/pengine/bundle.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,8 +1320,8 @@ replica_resource_active(pcmk_resource_t *rsc, gboolean all)
13201320
return -1;
13211321
}
13221322

1323-
gboolean
1324-
pe__bundle_active(pcmk_resource_t *rsc, gboolean all)
1323+
bool
1324+
pe__bundle_active(const pcmk_resource_t *rsc, bool all)
13251325
{
13261326
pe__bundle_variant_data_t *bundle_data = NULL;
13271327
GList *iter = NULL;
@@ -1333,22 +1333,22 @@ pe__bundle_active(pcmk_resource_t *rsc, gboolean all)
13331333

13341334
rsc_active = replica_resource_active(replica->ip, all);
13351335
if (rsc_active >= 0) {
1336-
return (gboolean) rsc_active;
1336+
return (bool) rsc_active;
13371337
}
13381338

13391339
rsc_active = replica_resource_active(replica->child, all);
13401340
if (rsc_active >= 0) {
1341-
return (gboolean) rsc_active;
1341+
return (bool) rsc_active;
13421342
}
13431343

13441344
rsc_active = replica_resource_active(replica->container, all);
13451345
if (rsc_active >= 0) {
1346-
return (gboolean) rsc_active;
1346+
return (bool) rsc_active;
13471347
}
13481348

13491349
rsc_active = replica_resource_active(replica->remote, all);
13501350
if (rsc_active >= 0) {
1351-
return (gboolean) rsc_active;
1351+
return (bool) rsc_active;
13521352
}
13531353
}
13541354

lib/pengine/clone.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -441,14 +441,14 @@ clone_unpack(pcmk_resource_t *rsc)
441441
return TRUE;
442442
}
443443

444-
gboolean
445-
clone_active(pcmk_resource_t * rsc, gboolean all)
444+
bool
445+
clone_active(const pcmk_resource_t *rsc, bool all)
446446
{
447447
for (GList *gIter = rsc->priv->children;
448448
gIter != NULL; gIter = gIter->next) {
449449

450450
pcmk_resource_t *child_rsc = (pcmk_resource_t *) gIter->data;
451-
gboolean child_active = child_rsc->priv->fns->active(child_rsc, all);
451+
bool child_active = child_rsc->priv->fns->active(child_rsc, all);
452452

453453
if (all == FALSE && child_active) {
454454
return TRUE;
@@ -649,8 +649,7 @@ pe__clone_default(pcmk__output_t *out, va_list args)
649649
for (gIter = rsc->priv->children; gIter != NULL; gIter = gIter->next) {
650650
gboolean print_full = FALSE;
651651
pcmk_resource_t *child_rsc = (pcmk_resource_t *) gIter->data;
652-
gboolean partially_active = child_rsc->priv->fns->active(child_rsc,
653-
FALSE);
652+
bool partially_active = child_rsc->priv->fns->active(child_rsc, false);
654653

655654
if (pcmk__rsc_filtered_by_node(child_rsc, only_node)) {
656655
continue;
@@ -699,7 +698,7 @@ pe__clone_default(pcmk__output_t *out, va_list args)
699698
// Print individual instance when active orphaned/unmanaged/failed
700699
print_full = TRUE;
701700

702-
} else if (child_rsc->priv->fns->active(child_rsc, TRUE)) {
701+
} else if (child_rsc->priv->fns->active(child_rsc, true)) {
703702
// Instance of fully active anonymous clone
704703

705704
pcmk_node_t *location = NULL;

lib/pengine/group.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ inactive_resources(pcmk_resource_t *rsc)
108108

109109
pcmk_resource_t *child_rsc = (pcmk_resource_t *) gIter->data;
110110

111-
if (!child_rsc->priv->fns->active(child_rsc, TRUE)) {
111+
if (!child_rsc->priv->fns->active(child_rsc, true)) {
112112
retval++;
113113
}
114114
}
@@ -160,7 +160,7 @@ skip_child_rsc(pcmk_resource_t *rsc, pcmk_resource_t *child,
160160
bool star_list = pcmk__list_of_1(only_rsc) &&
161161
pcmk__str_eq("*", g_list_first(only_rsc)->data, pcmk__str_none);
162162
bool child_filtered = child->priv->fns->is_filtered(child, only_rsc, FALSE);
163-
bool child_active = child->priv->fns->active(child, FALSE);
163+
bool child_active = child->priv->fns->active(child, false);
164164
bool show_inactive = pcmk_is_set(show_opts, pcmk_show_inactive_rscs);
165165

166166
/* If the resource is in only_rsc by name (so, ignoring "*") then allow
@@ -231,8 +231,8 @@ group_unpack(pcmk_resource_t *rsc)
231231
return TRUE;
232232
}
233233

234-
gboolean
235-
group_active(pcmk_resource_t *rsc, gboolean all)
234+
bool
235+
group_active(const pcmk_resource_t *rsc, bool all)
236236
{
237237
gboolean c_all = TRUE;
238238
gboolean c_any = FALSE;
@@ -336,8 +336,8 @@ pe__group_default(pcmk__output_t *out, va_list args)
336336
gboolean parent_passes = pcmk__str_in_list(rsc_printable_id(rsc), only_rsc, pcmk__str_star_matches) ||
337337
(strstr(rsc->id, ":") != NULL && pcmk__str_in_list(rsc->id, only_rsc, pcmk__str_star_matches));
338338

339-
gboolean active = rsc->priv->fns->active(rsc, TRUE);
340-
gboolean partially_active = rsc->priv->fns->active(rsc, FALSE);
339+
bool active = rsc->priv->fns->active(rsc, true);
340+
bool partially_active = rsc->priv->fns->active(rsc, false);
341341

342342
desc = pe__resource_description(rsc, show_opts);
343343

lib/pengine/native.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,8 @@ native_find_rsc(pcmk_resource_t *rsc, const char *id,
321321
return NULL;
322322
}
323323

324-
gboolean
325-
native_active(pcmk_resource_t * rsc, gboolean all)
324+
bool
325+
native_active(const pcmk_resource_t *rsc, bool all)
326326
{
327327
for (GList *gIter = rsc->priv->active_nodes;
328328
gIter != NULL; gIter = gIter->next) {
@@ -741,7 +741,7 @@ pe__resource_xml(pcmk__output_t *out, va_list args)
741741
char ra_name[LINE_MAX];
742742
const char *rsc_state = native_displayable_state(rsc, print_pending);
743743
const char *target_role = NULL;
744-
const char *active = pcmk__btoa(rsc->priv->fns->active(rsc, TRUE));
744+
const char *active = pcmk__btoa(rsc->priv->fns->active(rsc, true));
745745
const char *orphaned = pcmk__flag_text(rsc->flags, pcmk__rsc_removed);
746746
const char *blocked = pcmk__flag_text(rsc->flags, pcmk__rsc_blocked);
747747
const char *maintenance = pcmk__flag_text(rsc->flags,

lib/pengine/pe_actions.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2004-2024 the Pacemaker project contributors
2+
* Copyright 2004-2025 the Pacemaker project contributors
33
*
44
* The version control history for this file may have further details.
55
*
@@ -389,7 +389,7 @@ update_resource_action_runnable(pcmk_action_t *action,
389389
break;
390390

391391
case pcmk_no_quorum_freeze:
392-
if (!rsc->priv->fns->active(rsc, TRUE)
392+
if (!rsc->priv->fns->active(rsc, true)
393393
|| (rsc->priv->next_role > rsc->priv->orig_role)) {
394394
pcmk__rsc_debug(rsc, "%s on %s is unrunnable (no quorum)",
395395
action->uuid,

lib/pengine/pe_output.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2024 the Pacemaker project contributors
2+
* Copyright 2019-2025 the Pacemaker project contributors
33
*
44
* The version control history for this file may have further details.
55
*
@@ -3060,8 +3060,8 @@ resource_list(pcmk__output_t *out, va_list args)
30603060
int x;
30613061

30623062
/* Complex resources may have some sub-resources active and some inactive */
3063-
gboolean is_active = rsc->priv->fns->active(rsc, TRUE);
3064-
gboolean partially_active = rsc->priv->fns->active(rsc, FALSE);
3063+
bool is_active = rsc->priv->fns->active(rsc, true);
3064+
bool partially_active = rsc->priv->fns->active(rsc, false);
30653065

30663066
/* Skip inactive orphans (deleted but still in CIB) */
30673067
if (pcmk_is_set(rsc->flags, pcmk__rsc_removed) && !is_active) {

lib/pengine/utils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2004-2024 the Pacemaker project contributors
2+
* Copyright 2004-2025 the Pacemaker project contributors
33
*
44
* The version control history for this file may have further details.
55
*
@@ -747,7 +747,7 @@ pe__rsc_running_on_any(pcmk_resource_t *rsc, GList *node_list)
747747
bool
748748
pcmk__rsc_filtered_by_node(pcmk_resource_t *rsc, GList *only_node)
749749
{
750-
return rsc->priv->fns->active(rsc, FALSE)
750+
return rsc->priv->fns->active(rsc, false)
751751
&& !pe__rsc_running_on_any(rsc, only_node);
752752
}
753753

0 commit comments

Comments
 (0)