Skip to content

Commit 4540673

Browse files
authored
Merge pull request #3804 from nrwahl2/nrwahl2-refactor
Refactor: various: Drop pcmk__xe_add_node()
2 parents 47b8613 + 6675f20 commit 4540673

File tree

8 files changed

+21
-116
lines changed

8 files changed

+21
-116
lines changed

daemons/attrd/attrd_ipc.c

Lines changed: 4 additions & 4 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
*
@@ -66,7 +66,7 @@ static xmlNode *build_query_reply(const char *attr, const char *host)
6666
if (host) {
6767
v = g_hash_table_lookup(a->values, host);
6868
host_value = pcmk__xe_create(reply, PCMK_XE_NODE);
69-
pcmk__xe_add_node(host_value, host, 0);
69+
crm_xml_add(host_value, PCMK__XA_ATTR_HOST, host);
7070
crm_xml_add(host_value, PCMK__XA_ATTR_VALUE,
7171
(v? v->current : NULL));
7272

@@ -77,7 +77,7 @@ static xmlNode *build_query_reply(const char *attr, const char *host)
7777
g_hash_table_iter_init(&iter, a->values);
7878
while (g_hash_table_iter_next(&iter, NULL, (gpointer *) &v)) {
7979
host_value = pcmk__xe_create(reply, PCMK_XE_NODE);
80-
pcmk__xe_add_node(host_value, v->nodename, 0);
80+
crm_xml_add(host_value, PCMK__XA_ATTR_HOST, v->nodename);
8181
crm_xml_add(host_value, PCMK__XA_ATTR_VALUE, v->current);
8282
}
8383
}
@@ -166,7 +166,7 @@ attrd_client_peer_remove(pcmk__request_t *request)
166166
host_alloc = pcmk__cluster_node_name(nodeid);
167167
host = host_alloc;
168168
}
169-
pcmk__xe_add_node(xml, host, 0);
169+
crm_xml_add(xml, PCMK__XA_ATTR_HOST, host);
170170
}
171171
}
172172

include/crm/common/internal.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the Pacemaker project contributors
2+
* Copyright 2015-2025 the Pacemaker project contributors
33
*
44
* The version control history for this file may have further details.
55
*
@@ -64,19 +64,6 @@ int pcmk__add_mainloop_ipc(crm_ipc_t *ipc, int priority, void *userdata,
6464
guint pcmk__mainloop_timer_get_period(const mainloop_timer_t *timer);
6565

6666

67-
/* internal node-related XML utilities (from nodes.c) */
68-
69-
/*!
70-
* \internal
71-
* \brief Add local node name and ID to an XML node
72-
*
73-
* \param[in,out] request XML node to modify
74-
* \param[in] node The local node's name
75-
* \param[in] nodeid The local node's ID (can be 0)
76-
*/
77-
void pcmk__xe_add_node(xmlNode *xml, const char *node, int nodeid);
78-
79-
8067
/* internal name/value utilities (from nvpair.c) */
8168

8269
int pcmk__scan_nvpair(const char *input, char **name, char **value);

lib/common/ipc_attrd.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2011-2024 the Pacemaker project contributors
2+
* Copyright 2011-2025 the Pacemaker project contributors
33
*
44
* The version control history for this file may have further details.
55
*
@@ -201,7 +201,7 @@ pcmk__attrd_api_clear_failures(pcmk_ipc_api_t *api, const char *node,
201201
pcmk__s(resource, "all resources"), pcmk__s(node, "all nodes"));
202202

203203
crm_xml_add(request, PCMK_XA_TASK, PCMK__ATTRD_CMD_CLEAR_FAILURE);
204-
pcmk__xe_add_node(request, node, 0);
204+
crm_xml_add(request, PCMK__XA_ATTR_HOST, node);
205205
crm_xml_add(request, PCMK__XA_ATTR_RESOURCE, resource);
206206
crm_xml_add(request, PCMK__XA_ATTR_CLEAR_OPERATION, operation);
207207
crm_xml_add(request, PCMK__XA_ATTR_CLEAR_INTERVAL, interval_spec);
@@ -257,7 +257,7 @@ pcmk__attrd_api_purge(pcmk_ipc_api_t *api, const char *node, bool reap)
257257

258258
crm_xml_add(request, PCMK_XA_TASK, PCMK__ATTRD_CMD_PEER_REMOVE);
259259
pcmk__xe_set_bool_attr(request, PCMK__XA_REAP, reap);
260-
pcmk__xe_add_node(request, node, 0);
260+
crm_xml_add(request, PCMK__XA_ATTR_HOST, node);
261261

262262
rc = connect_and_send_attrd_request(api, request);
263263

@@ -297,7 +297,7 @@ pcmk__attrd_api_query(pcmk_ipc_api_t *api, const char *node, const char *name,
297297

298298
crm_xml_add(request, PCMK__XA_ATTR_NAME, name);
299299
crm_xml_add(request, PCMK_XA_TASK, PCMK__ATTRD_CMD_QUERY);
300-
pcmk__xe_add_node(request, node, 0);
300+
crm_xml_add(request, PCMK__XA_ATTR_HOST, node);
301301

302302
rc = connect_and_send_attrd_request(api, request);
303303
pcmk__xml_free(request);
@@ -321,7 +321,7 @@ pcmk__attrd_api_refresh(pcmk_ipc_api_t *api, const char *node)
321321
request = create_attrd_op(NULL);
322322

323323
crm_xml_add(request, PCMK_XA_TASK, PCMK__ATTRD_CMD_REFRESH);
324-
pcmk__xe_add_node(request, node, 0);
324+
crm_xml_add(request, PCMK__XA_ATTR_HOST, node);
325325

326326
rc = connect_and_send_attrd_request(api, request);
327327

@@ -361,7 +361,7 @@ populate_update_op(xmlNode *op, const char *node, const char *name, const char *
361361

362362
crm_xml_add(op, PCMK__XA_ATTR_VALUE, value);
363363
crm_xml_add(op, PCMK__XA_ATTR_DAMPENING, dampen);
364-
pcmk__xe_add_node(op, node, 0);
364+
crm_xml_add(op, PCMK__XA_ATTR_HOST, node);
365365
crm_xml_add(op, PCMK__XA_ATTR_SET, set);
366366
crm_xml_add_int(op, PCMK__XA_ATTR_IS_REMOTE,
367367
pcmk_is_set(options, pcmk__node_attr_remote));

lib/common/ipc_client.c

Lines changed: 5 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
*
@@ -754,7 +754,10 @@ create_purge_node_request(const pcmk_ipc_api_t *api, const char *node_name,
754754
crm_xml_add(request, PCMK__XA_SRC, crm_system_name);
755755
crm_xml_add(request, PCMK_XA_TASK, PCMK__ATTRD_CMD_PEER_REMOVE);
756756
pcmk__xe_set_bool_attr(request, PCMK__XA_REAP, true);
757-
pcmk__xe_add_node(request, node_name, nodeid);
757+
crm_xml_add(request, PCMK__XA_ATTR_HOST, node_name);
758+
if (nodeid > 0) {
759+
crm_xml_add_int(request, PCMK__XA_ATTR_HOST_ID, nodeid);
760+
}
758761
break;
759762

760763
case pcmk_ipc_controld:

lib/common/nodes.c

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022-2024 the Pacemaker project contributors
2+
* Copyright 2022-2025 the Pacemaker project contributors
33
*
44
* The version control history for this file may have further details.
55
*
@@ -185,20 +185,6 @@ pcmk_foreach_active_resource(pcmk_node_t *node,
185185
return result;
186186
}
187187

188-
void
189-
pcmk__xe_add_node(xmlNode *xml, const char *node, int nodeid)
190-
{
191-
pcmk__assert(xml != NULL);
192-
193-
if (node != NULL) {
194-
crm_xml_add(xml, PCMK__XA_ATTR_HOST, node);
195-
}
196-
197-
if (nodeid > 0) {
198-
crm_xml_add_int(xml, PCMK__XA_ATTR_HOST_ID, nodeid);
199-
}
200-
}
201-
202188
/*!
203189
* \internal
204190
* \brief Find a node by name in a list of nodes

lib/common/tests/nodes/Makefile.am

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright 2024 the Pacemaker project contributors
2+
# Copyright 2024-2025 the Pacemaker project contributors
33
#
44
# The version control history for this file may have further details.
55
#
@@ -13,7 +13,6 @@ include $(top_srcdir)/mk/unittest.mk
1313

1414
# Add "_test" to the end of all test program names to simplify .gitignore.
1515
check_PROGRAMS = pcmk__find_node_in_list_test \
16-
pcmk__xe_add_node_test \
1716
pcmk_cib_node_shutdown_test \
1817
pcmk_foreach_active_resource_test \
1918
pcmk_node_is_clean_test \

lib/common/tests/nodes/pcmk__xe_add_node_test.c

Lines changed: 0 additions & 71 deletions
This file was deleted.

lib/lrmd/proxy_common.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015-2024 the Pacemaker project contributors
2+
* Copyright 2015-2025 the Pacemaker project contributors
33
*
44
* The version control history for this file may have further details.
55
*
@@ -281,7 +281,8 @@ remote_proxy_cb(lrmd_t *lrmd, const char *node_name, xmlNode *msg)
281281
PCMK__ATTRD_CMD_UPDATE,
282282
PCMK__ATTRD_CMD_UPDATE_BOTH,
283283
PCMK__ATTRD_CMD_UPDATE_DELAY, NULL)) {
284-
pcmk__xe_add_node(request, proxy->node_name, 0);
284+
285+
crm_xml_add(request, PCMK__XA_ATTR_HOST, proxy->node_name);
285286
}
286287

287288
rc = crm_ipc_send(proxy->ipc, request, flags, 5000, NULL);

0 commit comments

Comments
 (0)