Skip to content

Commit 3db2f3e

Browse files
committed
Refactor: libcib: Drop cib_diff_version_details()
It's a simple wrapper around pcmk__xml_patchset_versions but requires seven arguments. Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
1 parent 35c967d commit 3db2f3e

4 files changed

Lines changed: 19 additions & 56 deletions

File tree

daemons/based/based_messages.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -309,23 +309,17 @@ cib_server_process_diff(const char *op, int options, const char *section, xmlNod
309309

310310
// The primary instance should never ignore a diff
311311
if (sync_in_progress && !based_is_primary) {
312-
int diff_add_updates = 0;
313-
int diff_add_epoch = 0;
314-
int diff_add_admin_epoch = 0;
312+
int source[] = { 0, 0, 0 };
313+
int target[] = { 0, 0, 0 };
315314

316-
int diff_del_updates = 0;
317-
int diff_del_epoch = 0;
318-
int diff_del_admin_epoch = 0;
319-
320-
cib_diff_version_details(input,
321-
&diff_add_admin_epoch, &diff_add_epoch, &diff_add_updates,
322-
&diff_del_admin_epoch, &diff_del_epoch, &diff_del_updates);
315+
// @TODO Check return code
316+
pcmk__xml_patchset_versions(input, source, target);
323317

324318
sync_in_progress++;
325319
pcmk__notice("Not applying diff %d.%d.%d -> %d.%d.%d (sync in "
326320
"progress)",
327-
diff_del_admin_epoch, diff_del_epoch, diff_del_updates,
328-
diff_add_admin_epoch, diff_add_epoch, diff_add_updates);
321+
source[0], source[1], source[2],
322+
target[0], target[1], target[2]);
329323
return -pcmk_err_diff_resync;
330324
}
331325

daemons/based/based_notify.c

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,8 @@ based_diff_notify(const char *op, int result, const char *call_id,
155155
const char *client_id, const char *client_name,
156156
const char *origin, xmlNode *update, xmlNode *diff)
157157
{
158-
int add_updates = 0;
159-
int add_epoch = 0;
160-
int add_admin_epoch = 0;
161-
162-
int del_updates = 0;
163-
int del_epoch = 0;
164-
int del_admin_epoch = 0;
158+
int source[] = { 0, 0, 0 };
159+
int target[] = { 0, 0, 0 };
165160

166161
uint8_t log_level = LOG_TRACE;
167162

@@ -176,31 +171,28 @@ based_diff_notify(const char *op, int result, const char *call_id,
176171
log_level = LOG_WARNING;
177172
}
178173

179-
cib_diff_version_details(diff, &add_admin_epoch, &add_epoch, &add_updates,
180-
&del_admin_epoch, &del_epoch, &del_updates);
174+
/* @TODO Check return code? How should we handle an error? Are these log
175+
* messages even useful?
176+
*/
177+
pcmk__xml_patchset_versions(diff, source, target);
181178

182-
if ((add_admin_epoch != del_admin_epoch)
183-
|| (add_epoch != del_epoch)
184-
|| (add_updates != del_updates)) {
179+
if ((source[0] != target[0])
180+
|| (source[1] != target[1])
181+
|| (source[2] != target[2])) {
185182

186183
do_crm_log(log_level,
187184
"Updated CIB generation %d.%d.%d to %d.%d.%d from client "
188185
"%s%s%s (%s) (%s)",
189-
del_admin_epoch, del_epoch, del_updates,
190-
add_admin_epoch, add_epoch, add_updates,
191-
client_name,
186+
source[0], source[1], source[2],
187+
target[0], target[1], target[2], client_name,
192188
((call_id != NULL)? " call " : ""), pcmk__s(call_id, ""),
193189
pcmk__s(origin, "unspecified peer"), pcmk_strerror(result));
194190

195-
} else if ((add_admin_epoch != 0)
196-
|| (add_epoch != 0)
197-
|| (add_updates != 0)) {
198-
191+
} else if ((target[0] != 0) || (target[1] != 0) || (target[2] != 0)) {
199192
do_crm_log(log_level,
200193
"Local-only change to CIB generation %d.%d.%d from client "
201194
"%s%s%s (%s) (%s)",
202-
add_admin_epoch, add_epoch, add_updates,
203-
client_name,
195+
target[0], target[1], target[2], client_name,
204196
((call_id != NULL)? " call " : ""), pcmk__s(call_id, ""),
205197
pcmk__s(origin, "unspecified peer"), pcmk_strerror(result));
206198
}

include/crm/cib/internal.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,6 @@ enum cib__op_type {
9898
cib__op_schemas,
9999
};
100100

101-
gboolean cib_diff_version_details(xmlNode * diff, int *admin_epoch, int *epoch, int *updates,
102-
int *_admin_epoch, int *_epoch, int *_updates);
103-
104101
gboolean cib_read_config(GHashTable * options, xmlNode * current_cib);
105102

106103
typedef int (*cib__op_fn_t)(const char *, int, const char *, xmlNode *,

lib/cib/cib_utils.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,6 @@ cib_version_details(xmlNode * cib, int *admin_epoch, int *epoch, int *updates)
4141
return TRUE;
4242
}
4343

44-
gboolean
45-
cib_diff_version_details(xmlNode * diff, int *admin_epoch, int *epoch, int *updates,
46-
int *_admin_epoch, int *_epoch, int *_updates)
47-
{
48-
int add[] = { 0, 0, 0 };
49-
int del[] = { 0, 0, 0 };
50-
51-
pcmk__xml_patchset_versions(diff, del, add);
52-
53-
*admin_epoch = add[0];
54-
*epoch = add[1];
55-
*updates = add[2];
56-
57-
*_admin_epoch = del[0];
58-
*_epoch = del[1];
59-
*_updates = del[2];
60-
61-
return TRUE;
62-
}
63-
6444
/*!
6545
* \internal
6646
* \brief Get the XML patchset from a CIB diff notification

0 commit comments

Comments
 (0)