Skip to content

Commit 5159fb9

Browse files
committed
Refactor: libcib: Drop op arg from cib__op_fn_t
The request argument provides the op value for functions that need it. Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
1 parent e6c27ab commit 5159fb9

6 files changed

Lines changed: 99 additions & 134 deletions

File tree

daemons/based/based_messages.c

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ xmlNode *the_cib = NULL;
4141
* \internal
4242
* \brief Process a \c PCMK__CIB_REQUEST_ABS_DELETE
4343
*
44-
* \param[in] op Ignored
4544
* \param[in] options Ignored
4645
* \param[in] section Ignored
4746
* \param[in] req Ignored
@@ -54,9 +53,8 @@ xmlNode *the_cib = NULL;
5453
* \note This is unimplemented and simply returns an error.
5554
*/
5655
int
57-
based_process_abs_delete(const char *op, int options, const char *section,
58-
xmlNode *req, xmlNode *input, xmlNode **cib,
59-
xmlNode **answer)
56+
based_process_abs_delete(int options, const char *section, xmlNode *req,
57+
xmlNode *input, xmlNode **cib, xmlNode **answer)
6058
{
6159
/* @COMPAT Remove when PCMK__CIB_REQUEST_ABS_DELETE is removed. Note that
6260
* external clients with Pacemaker versions < 3.0.0 can send it.
@@ -65,9 +63,8 @@ based_process_abs_delete(const char *op, int options, const char *section,
6563
}
6664

6765
int
68-
based_process_commit_transact(const char *op, int options, const char *section,
69-
xmlNode *req, xmlNode *input, xmlNode **cib,
70-
xmlNode **answer)
66+
based_process_commit_transact(int options, const char *section, xmlNode *req,
67+
xmlNode *input, xmlNode **cib, xmlNode **answer)
7168
{
7269
/* On success, our caller will activate *cib locally, trigger a replace
7370
* notification if appropriate, and sync *cib to all nodes. On failure, our
@@ -91,28 +88,25 @@ based_process_commit_transact(const char *op, int options, const char *section,
9188
}
9289

9390
int
94-
based_process_is_primary(const char *op, int options, const char *section,
95-
xmlNode *req, xmlNode *input, xmlNode **cib,
96-
xmlNode **answer)
91+
based_process_is_primary(int options, const char *section, xmlNode *req,
92+
xmlNode *input, xmlNode **cib, xmlNode **answer)
9793
{
9894
// @COMPAT Pacemaker Remote clients <3.0.0 may send this
9995
return (based_is_primary? pcmk_rc_ok : EPERM);
10096
}
10197

10298
// @COMPAT: Remove when PCMK__CIB_REQUEST_NOOP is removed
10399
int
104-
based_process_noop(const char *op, int options, const char *section,
105-
xmlNode *req, xmlNode *input, xmlNode **cib,
106-
xmlNode **answer)
100+
based_process_noop(int options, const char *section, xmlNode *req,
101+
xmlNode *input, xmlNode **cib, xmlNode **answer)
107102
{
108103
*answer = NULL;
109104
return pcmk_rc_ok;
110105
}
111106

112107
int
113-
based_process_ping(const char *op, int options, const char *section,
114-
xmlNode *req, xmlNode *input, xmlNode **cib,
115-
xmlNode **answer)
108+
based_process_ping(int options, const char *section, xmlNode *req,
109+
xmlNode *input, xmlNode **cib, xmlNode **answer)
116110
{
117111
const char *host = pcmk__xe_get(req, PCMK__XA_SRC);
118112
const char *seq = pcmk__xe_get(req, PCMK__XA_CIB_PING_ID);
@@ -146,9 +140,8 @@ based_process_ping(const char *op, int options, const char *section,
146140
}
147141

148142
int
149-
based_process_primary(const char *op, int options, const char *section,
150-
xmlNode *req, xmlNode *input, xmlNode **cib,
151-
xmlNode **answer)
143+
based_process_primary(int options, const char *section, xmlNode *req,
144+
xmlNode *input, xmlNode **cib, xmlNode **answer)
152145
{
153146
if (!based_is_primary) {
154147
pcmk__info("We are now in R/W mode");
@@ -162,9 +155,8 @@ based_process_primary(const char *op, int options, const char *section,
162155
}
163156

164157
int
165-
based_process_schemas(const char *op, int options, const char *section,
166-
xmlNode *req, xmlNode *input, xmlNode **cib,
167-
xmlNode **answer)
158+
based_process_schemas(int options, const char *section, xmlNode *req,
159+
xmlNode *input, xmlNode **cib, xmlNode **answer)
168160
{
169161
xmlNode *wrapper = NULL;
170162
xmlNode *data = NULL;
@@ -208,9 +200,8 @@ based_process_schemas(const char *op, int options, const char *section,
208200
}
209201

210202
int
211-
based_process_secondary(const char *op, int options, const char *section,
212-
xmlNode *req, xmlNode *input, xmlNode **cib,
213-
xmlNode **answer)
203+
based_process_secondary(int options, const char *section, xmlNode *req,
204+
xmlNode *input, xmlNode **cib, xmlNode **answer)
214205
{
215206
if (based_is_primary) {
216207
pcmk__info("We are now in R/O mode");
@@ -224,9 +215,8 @@ based_process_secondary(const char *op, int options, const char *section,
224215
}
225216

226217
int
227-
based_process_shutdown(const char *op, int options, const char *section,
228-
xmlNode *req, xmlNode *input, xmlNode **cib,
229-
xmlNode **answer)
218+
based_process_shutdown(int options, const char *section, xmlNode *req,
219+
xmlNode *input, xmlNode **cib, xmlNode **answer)
230220
{
231221
const char *host = pcmk__xe_get(req, PCMK__XA_SRC);
232222

@@ -248,17 +238,15 @@ based_process_shutdown(const char *op, int options, const char *section,
248238
}
249239

250240
int
251-
based_process_sync(const char *op, int options, const char *section,
252-
xmlNode *req, xmlNode *input, xmlNode **cib,
253-
xmlNode **answer)
241+
based_process_sync(int options, const char *section, xmlNode *req,
242+
xmlNode *input, xmlNode **cib, xmlNode **answer)
254243
{
255244
return sync_our_cib(req, true);
256245
}
257246

258247
int
259-
based_process_upgrade(const char *op, int options, const char *section,
260-
xmlNode *req, xmlNode *input, xmlNode **cib,
261-
xmlNode **answer)
248+
based_process_upgrade(int options, const char *section, xmlNode *req,
249+
xmlNode *input, xmlNode **cib, xmlNode **answer)
262250
{
263251
int rc = pcmk_rc_ok;
264252

@@ -270,8 +258,7 @@ based_process_upgrade(const char *op, int options, const char *section,
270258
* re-broadcasts the request with PCMK__XA_CIB_SCHEMA_MAX, and each node
271259
* performs the upgrade (and notifies its local clients) here.
272260
*/
273-
return cib__process_upgrade(op, options, section, req, input, cib,
274-
answer);
261+
return cib__process_upgrade(options, section, req, input, cib, answer);
275262

276263
} else {
277264
xmlNode *scratch = pcmk__xml_copy(NULL, *cib);

daemons/based/based_messages.h

Lines changed: 24 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,54 +17,42 @@
1717
extern bool based_is_primary;
1818
extern xmlNode *the_cib;
1919

20-
int based_process_abs_delete(const char *op, int options, const char *section,
21-
xmlNode *req, xmlNode *input, xmlNode **cib,
22-
xmlNode **answer);
20+
int based_process_abs_delete(int options, const char *section, xmlNode *req,
21+
xmlNode *input, xmlNode **cib, xmlNode **answer);
2322

24-
int based_process_apply_patch(const char *op, int options, const char *section,
25-
xmlNode *req, xmlNode *input, xmlNode **cib,
26-
xmlNode **answer);
23+
int based_process_apply_patch(int options, const char *section, xmlNode *req,
24+
xmlNode *input, xmlNode **cib, xmlNode **answer);
2725

28-
int based_process_commit_transact(const char *op, int options,
29-
const char *section, xmlNode *req,
30-
xmlNode *input, xmlNode **cib,
26+
int based_process_commit_transact(int options, const char *section,
27+
xmlNode *req, xmlNode *input, xmlNode **cib,
3128
xmlNode **answer);
3229

33-
int based_process_is_primary(const char *op, int options, const char *section,
34-
xmlNode *req, xmlNode *input, xmlNode **cib,
35-
xmlNode **answer);
30+
int based_process_is_primary(int options, const char *section, xmlNode *req,
31+
xmlNode *input, xmlNode **cib, xmlNode **answer);
3632

37-
int based_process_noop(const char *op, int options, const char *section,
38-
xmlNode *req, xmlNode *input, xmlNode **cib,
39-
xmlNode **answer);
33+
int based_process_noop(int options, const char *section, xmlNode *req,
34+
xmlNode *input, xmlNode **cib, xmlNode **answer);
4035

41-
int based_process_ping(const char *op, int options, const char *section,
42-
xmlNode *req, xmlNode *input, xmlNode **cib,
43-
xmlNode **answer);
36+
int based_process_ping(int options, const char *section, xmlNode *req,
37+
xmlNode *input, xmlNode **cib, xmlNode **answer);
4438

45-
int based_process_primary(const char *op, int options, const char *section,
46-
xmlNode *req, xmlNode *input, xmlNode **cib,
47-
xmlNode **answer);
39+
int based_process_primary(int options, const char *section, xmlNode *req,
40+
xmlNode *input, xmlNode **cib, xmlNode **answer);
4841

49-
int based_process_schemas(const char *op, int options, const char *section,
50-
xmlNode *req, xmlNode *input, xmlNode **cib,
51-
xmlNode **answer);
42+
int based_process_schemas(int options, const char *section, xmlNode *req,
43+
xmlNode *input, xmlNode **cib, xmlNode **answer);
5244

53-
int based_process_secondary(const char *op, int options, const char *section,
54-
xmlNode *req, xmlNode *input, xmlNode **cib,
55-
xmlNode **answer);
45+
int based_process_secondary(int options, const char *section, xmlNode *req,
46+
xmlNode *input, xmlNode **cib, xmlNode **answer);
5647

57-
int based_process_shutdown(const char *op, int options, const char *section,
58-
xmlNode *req, xmlNode *input, xmlNode **cib,
59-
xmlNode **answer);
48+
int based_process_shutdown(int options, const char *section, xmlNode *req,
49+
xmlNode *input, xmlNode **cib, xmlNode **answer);
6050

61-
int based_process_sync(const char *op, int options, const char *section,
62-
xmlNode *req, xmlNode *input, xmlNode **cib,
63-
xmlNode **answer);
51+
int based_process_sync(int options, const char *section, xmlNode *req,
52+
xmlNode *input, xmlNode **cib, xmlNode **answer);
6453

65-
int based_process_upgrade(const char *op, int options, const char *section,
66-
xmlNode *req, xmlNode *input, xmlNode **cib,
67-
xmlNode **answer);
54+
int based_process_upgrade(int options, const char *section, xmlNode *req,
55+
xmlNode *input, xmlNode **cib, xmlNode **answer);
6856

6957
int sync_our_cib(xmlNode *request, bool all);
7058

include/crm/cib/internal.h

Lines changed: 20 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,8 @@ enum cib__op_type {
106106
* replace *cib, but the replacement must become the root of the original
107107
* document.
108108
*/
109-
typedef int (*cib__op_fn_t)(const char *op, int options, const char *section,
110-
xmlNode *request, xmlNode *input, xmlNode **cib,
111-
xmlNode **output);
109+
typedef int (*cib__op_fn_t)(int options, const char *section, xmlNode *request,
110+
xmlNode *input, xmlNode **cib, xmlNode **output);
112111

113112
typedef struct cib__operation_s {
114113
const char *name;
@@ -211,41 +210,32 @@ void cib_native_notify(gpointer data, gpointer user_data);
211210

212211
int cib__get_operation(const char *op, const cib__operation_t **operation);
213212

214-
int cib__process_apply_patch(const char *op, int options, const char *section,
215-
xmlNode *req, xmlNode *input, xmlNode **cib,
216-
xmlNode **answer);
213+
int cib__process_apply_patch(int options, const char *section, xmlNode *req,
214+
xmlNode *input, xmlNode **cib, xmlNode **answer);
217215

218-
int cib__process_bump(const char *op, int options, const char *section,
219-
xmlNode *req, xmlNode *input, xmlNode **cib,
220-
xmlNode **answer);
216+
int cib__process_bump(int options, const char *section, xmlNode *req,
217+
xmlNode *input, xmlNode **cib, xmlNode **answer);
221218

222-
int cib__process_create(const char *op, int options, const char *section,
223-
xmlNode *req, xmlNode *input, xmlNode **cib,
224-
xmlNode **answer);
219+
int cib__process_create(int options, const char *section, xmlNode *req,
220+
xmlNode *input, xmlNode **cib, xmlNode **answer);
225221

226-
int cib__process_delete(const char *op, int options, const char *section,
227-
xmlNode *req, xmlNode *input, xmlNode **cib,
228-
xmlNode **answer);
222+
int cib__process_delete(int options, const char *section, xmlNode *req,
223+
xmlNode *input, xmlNode **cib, xmlNode **answer);
229224

230-
int cib__process_erase(const char *op, int options, const char *section,
231-
xmlNode *req, xmlNode *input, xmlNode **cib,
232-
xmlNode **answer);
225+
int cib__process_erase(int options, const char *section, xmlNode *req,
226+
xmlNode *input, xmlNode **cib, xmlNode **answer);
233227

234-
int cib__process_modify(const char *op, int options, const char *section,
235-
xmlNode *req, xmlNode *input, xmlNode **cib,
236-
xmlNode **answer);
228+
int cib__process_modify(int options, const char *section, xmlNode *req,
229+
xmlNode *input, xmlNode **cib, xmlNode **answer);
237230

238-
int cib__process_query(const char *op, int options, const char *section,
239-
xmlNode *req, xmlNode *input, xmlNode **cib,
240-
xmlNode **answer);
231+
int cib__process_query(int options, const char *section, xmlNode *req,
232+
xmlNode *input, xmlNode **cib, xmlNode **answer);
241233

242-
int cib__process_replace(const char *op, int options, const char *section,
243-
xmlNode *req, xmlNode *input, xmlNode **cib,
244-
xmlNode **answer);
234+
int cib__process_replace(int options, const char *section, xmlNode *req,
235+
xmlNode *input, xmlNode **cib, xmlNode **answer);
245236

246-
int cib__process_upgrade(const char *op, int options, const char *section,
247-
xmlNode *req, xmlNode *input, xmlNode **cib,
248-
xmlNode **answer);
237+
int cib__process_upgrade(int options, const char *section, xmlNode *req,
238+
xmlNode *input, xmlNode **cib, xmlNode **answer);
249239

250240
int cib_internal_op(cib_t * cib, const char *op, const char *host,
251241
const char *section, xmlNode * data,

lib/cib/cib_file.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,8 @@ commit_transaction(cib_t *cib, xmlNode *transaction, xmlNode **result_cib)
307307
}
308308

309309
static int
310-
process_commit_transact(const char *op, int options, const char *section,
311-
xmlNode *req, xmlNode *input, xmlNode **cib_xml,
312-
xmlNode **answer)
310+
process_commit_transact(int options, const char *section, xmlNode *req,
311+
xmlNode *input, xmlNode **cib_xml, xmlNode **answer)
313312
{
314313
int rc = pcmk_rc_ok;
315314
const char *client_id = pcmk__xe_get(req, PCMK__XA_CIB_CLIENTID);

0 commit comments

Comments
 (0)