Skip to content

Conversation

@nrwahl2
Copy link
Contributor

@nrwahl2 nrwahl2 commented Mar 5, 2025

Coverity is throwing some new false positives in #3832. Two of them are in code that I actually modified, but a lot more are in totally unrelated code in crm_resource. It's flagging NULL dereferences along code paths that are verifiably impossible to reach.

We could add Coverity suppressions. But false positives are often a sign that the code is too hard to follow in the first place. And I think that's the case here.

The changes that I've started on also happen to be first steps toward moving more functionality into libpacemaker.

The first few commits focus on avoiding passing around options.host_uname as much as possible. Coverity was complaining; it gets confusing to verify that it's non-NULL when it's supposed to be; and we're duplicating work with node lookups. Later commits mostly focus on breaking out the switch statement in main() into handler functions.

There's a lot more work to be done. For example, the new handler function bodies were basically copy-pasted from main(). They take as arguments only the things that were not already global. (For example, they don't take out as an argument, because it's a global variable.)

I haven't decided on what the end state will be. It might be a function table like we use for processing CIB operations. And there might be a set of enum flags that determine what objects (CIB connection, scheduler data, resource and node arguments, etc.) each operation needs or supports. That way we can run the necessary setup steps right before the operation, instead of calling is_scheduler_required() (etc.) near the top of main().

@nrwahl2 nrwahl2 requested a review from clumens March 5, 2025 07:38
@nrwahl2 nrwahl2 force-pushed the nrwahl2-crm_resource branch 3 times, most recently from 64284c6 to 230d36c Compare March 5, 2025 08:09
@nrwahl2 nrwahl2 force-pushed the nrwahl2-crm_resource branch 2 times, most recently from ad09ed7 to 5bb7fb3 Compare March 5, 2025 08:42
@nrwahl2 nrwahl2 force-pushed the nrwahl2-crm_resource branch from 5bb7fb3 to 9dc00b7 Compare March 5, 2025 19:29
@nrwahl2
Copy link
Contributor Author

nrwahl2 commented Mar 5, 2025

rebased on main

@nrwahl2 nrwahl2 marked this pull request as ready for review March 5, 2025 22:53
@nrwahl2
Copy link
Contributor Author

nrwahl2 commented Mar 5, 2025

retest this please

@nrwahl2 nrwahl2 force-pushed the nrwahl2-crm_resource branch 2 times, most recently from 4ecca90 to e5860dc Compare March 6, 2025 08:39
@clumens clumens added the review: in progress PRs that are currently being reviewed label Mar 6, 2025

g_list_free(before);
g_list_free(after);
g_list_free(remaining);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could apply some best practices here... move before, after, and remaining into this block; define ele in the for loop; remove the newline from the g_set_error string.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I didn't spend time thinking about the bodies of the handler functions or doing best practices; I just copy-pasted. I'll add a commit on top for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, can't do it with before. The whole point is that I'm grabbing those before I do anything else. I think I'll leave those alone for right now, except for ele and the newline in the g_set_error() string. (I'll just update the existing commit.)

@nrwahl2 nrwahl2 marked this pull request as draft March 6, 2025 20:45
@nrwahl2 nrwahl2 force-pushed the nrwahl2-crm_resource branch from e5860dc to 1fd785f Compare March 6, 2025 20:47
@nrwahl2
Copy link
Contributor Author

nrwahl2 commented Mar 6, 2025

Rebased on main and resolved conflicts. No other changes.

@nrwahl2 nrwahl2 force-pushed the nrwahl2-crm_resource branch from 1fd785f to d1deb42 Compare March 6, 2025 20:48
@nrwahl2
Copy link
Contributor Author

nrwahl2 commented Mar 6, 2025

No other changes.

Wrong :) There were a few extra commits that I'd added on my local branch. I just removed them and re-pushed.

@nrwahl2 nrwahl2 marked this pull request as ready for review March 6, 2025 21:33
@nrwahl2 nrwahl2 force-pushed the nrwahl2-crm_resource branch from d1deb42 to c7d5fbf Compare March 6, 2025 21:33
@nrwahl2
Copy link
Contributor Author

nrwahl2 commented Mar 6, 2025

Updated to address review

@nrwahl2 nrwahl2 force-pushed the nrwahl2-crm_resource branch from c7d5fbf to 6bf2e94 Compare March 7, 2025 02:19
@nrwahl2
Copy link
Contributor Author

nrwahl2 commented Mar 7, 2025

Fixed a Coverity suppression

@nrwahl2 nrwahl2 force-pushed the nrwahl2-crm_resource branch from 6bf2e94 to c85bd49 Compare March 7, 2025 02:31
@nrwahl2
Copy link
Contributor Author

nrwahl2 commented Mar 7, 2025

Fixed a commit history issue (no code change in the end result)

@clumens
Copy link
Contributor

clumens commented Mar 10, 2025

I think this looks fine. If you're happy, go ahead and rebase on main to deal with the merge conflict.

nrwahl2 added 26 commits March 10, 2025 11:32
And remove empty lines since each case is a one-liner plus the break.

Signed-off-by: Reid Wahl <[email protected]>
It's only called once and it's clearer to put its contents in the done
section of main().

Signed-off-by: Reid Wahl <[email protected]>
We can use a GString to build up a single buffer instead of building up
and printing an array of gchar strings.

Signed-off-by: Reid Wahl <[email protected]>
Allows us to avoid duplicating strings in main()

Signed-off-by: Reid Wahl <[email protected]>
@nrwahl2 nrwahl2 force-pushed the nrwahl2-crm_resource branch from c85bd49 to 9e934a5 Compare March 10, 2025 18:32
@nrwahl2 nrwahl2 merged commit 3573e5a into ClusterLabs:main Mar 10, 2025
1 check passed
@nrwahl2 nrwahl2 deleted the nrwahl2-crm_resource branch March 10, 2025 19:29
bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this pull request Mar 15, 2025
…R 1252999

https://build.opensuse.org/request/show/1252999
by user yan_gao + dimstar_suse
- tools: Fix memory leak in cli_resource_delete() (gh#ClusterLabs/pacemaker#3835) (forwarded request 1252998 from yan_gao)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: in progress PRs that are currently being reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants