Skip to content

Commit 53f67aa

Browse files
committed
Refactor: libcrmcommon: parse_acl_entry() specifies element in iterators
Use the second argument of pcmk__xe_first_child() and pcmk__xe_next() to specify what type of element to get (PCMK_XE_ACL_ROLE). Also unindent a block with pcmk__trace() in it, and use pcmk__xe_id(). Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
1 parent 1dd50f3 commit 53f67aa

1 file changed

Lines changed: 9 additions & 14 deletions

File tree

lib/common/acl.c

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -150,25 +150,20 @@ parse_acl_entry(const xmlNode *acl_top, const xmlNode *acl_entry, GList *acls)
150150
continue;
151151
}
152152

153-
for (xmlNode *role = pcmk__xe_first_child(acl_top, NULL, NULL,
154-
NULL);
155-
role != NULL; role = pcmk__xe_next(role, NULL)) {
153+
for (xmlNode *role = pcmk__xe_first_child(acl_top, PCMK_XE_ACL_ROLE,
154+
NULL, NULL);
155+
role != NULL; role = pcmk__xe_next(role, PCMK_XE_ACL_ROLE)) {
156156

157-
const char *role_id = NULL;
157+
const char *role_id = pcmk__xe_id(role);
158158

159-
if (!pcmk__xe_is(role, PCMK_XE_ACL_ROLE)) {
159+
if (!pcmk__str_eq(ref_role, role_id, pcmk__str_none)) {
160160
continue;
161161
}
162162

163-
role_id = pcmk__xe_get(role, PCMK_XA_ID);
164-
165-
if (pcmk__str_eq(ref_role, role_id, pcmk__str_none)) {
166-
pcmk__trace("Unpacking referenced role '%s' in <%s> "
167-
"element",
168-
role_id, acl_entry->name);
169-
acls = parse_acl_entry(acl_top, role, acls);
170-
break;
171-
}
163+
pcmk__trace("Unpacking referenced role '%s' in <%s> element",
164+
role_id, acl_entry->name);
165+
acls = parse_acl_entry(acl_top, role, acls);
166+
break;
172167
}
173168
}
174169
}

0 commit comments

Comments
 (0)