-
Notifications
You must be signed in to change notification settings - Fork 353
XML refactors: Simplify some attribute-related helpers #4045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
nrwahl2
wants to merge
22
commits into
ClusterLabs:main
Choose a base branch
from
nrwahl2:nrwahl2-acls_first
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I prefer to list the three meaningful values explicitly. Otherwise we could accept an arbitrary flag that happens to be set in the flag group. Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Use pcmk__xe_first_attr() and attr_is_not_id(). Signed-off-by: Reid Wahl <[email protected]>
Instead of creating an XPath string and looking for a substring. It seems clearer this way, though that is debatable. Signed-off-by: Reid Wahl <[email protected]>
Replace with g_str_has_prefix() in all but one place for clarity. The remaining place is pcmk__ipc_is_authentic_process_active(). In that case, use pcmk__str_eq(). Note that the former length argument was sizeof(last_asked_name), not sizeof(last_asked_name) - 1. This means we were checking whether the two strings were the same length and every character matched up to that length -- in other words, we were checking whether the strings were equal. Signed-off-by: Reid Wahl <[email protected]>
We return at the very beginning if attr->parent is NULL. element is then assigned attr->parent, so we know that element is not NULL. Signed-off-by: Reid Wahl <[email protected]>
The whole function seems clearer to me this way. Signed-off-by: Reid Wahl <[email protected]>
Notes: * The tracking flag can never be set when the argument is a document node. If node->_private is not NULL, we return before the switch statement. But pcmk__xml_doc_all_flags_set() returns false when the document's private data is NULL. So tracking is relevant only for element, attribute, and comment nodes. * pcmk__mark_xml_node_dirty() sets the pcmk__xf_dirty flag on the node itself as well as all of its parents. For an element, it doesn't matter whether we call it before or after creating the attributes' private data. Signed-off-by: Reid Wahl <[email protected]>
Nothing uses these yet. Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Also rename to reset_doc_private_data(), move the definition to a position below new_private_data() and above its first caller, and add Doxygen. Signed-off-by: Reid Wahl <[email protected]>
To enable this, functionize the pieces of free_private_data(). Signed-off-by: Reid Wahl <[email protected]>
Also rename attr_iter to old_attr and drop the declaration of old_attr within the body. Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
More precisely, replace xml_diff_old_attrs(). Functionize the for loop body and call the new function through pcmk__xe_foreach_attr(). Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
We can assume that the old and new XML elements are of the same type. Signed-off-by: Reid Wahl <[email protected]>
Also rename attr_iter to attr, rename attr_name to name, and drop new_attr variable. Signed-off-by: Reid Wahl <[email protected]>
Signed-off-by: Reid Wahl <[email protected]>
Replace mark_created_attrs(). Functionize the for loop body and call the new function through pcmk__xe_foreach_attr(). Signed-off-by: Reid Wahl <[email protected]>
Use with pcmk__xe_foreach_attr(). Signed-off-by: Reid Wahl <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
And other assorted changes. This is the next batch from #4013.