Skip to content
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

Split up parse config function #739

Merged
merged 4 commits into from
Feb 14, 2024

Conversation

engelmi
Copy link
Member

@engelmi engelmi commented Feb 13, 2024

Relates to: #678

The parse functions agent_parse_config and controller_parse_config initialize the config, set default values there, load configuration from all sources and sets the loaded values to the agent/controller fields. This is a bit much, therefore, split setting the values out to a dedicated function. In addition to a smaller, easier to read function it also simplifies writing unit tests - which are also added in this PR.

It also fixes two memory leaks:

  • agent_unref did not free the peer_socket_options
  • unit_infos was allocated twice

@engelmi engelmi force-pushed the split-up-parse-config-function branch 2 times, most recently from 80c6499 to 30ecf62 Compare February 13, 2024 10:11
@coveralls
Copy link

coveralls commented Feb 13, 2024

Coverage Status

coverage: 66.134% (-2.9%) from 69.003%
when pulling 71662b0 on engelmi:split-up-parse-config-function
into 249e092 on eclipse-bluechi:main.

Copy link
Member

@mwperina mwperina left a comment

Choose a reason for hiding this comment

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

Generally looks great, maybe just 2 suggestions for different name

src/agent/agent.c Outdated Show resolved Hide resolved
src/controller/controller.c Outdated Show resolved Hide resolved
Relates to: eclipse-bluechi#678

The parse functions agent_parse_config and controller_parse_config
initialize the config, set default values there, load configuration
from all sources and sets the loaded values to the agent/controller
fields.
This is a bit much, therefore, split setting the values out to a
dedicated function. In addition to a smaller, easier to read
function it also simplifies writing unit tests.

Signed-off-by: Michael Engel <mengel@redhat.com>
Relates to: eclipse-bluechi#678

Added unit tests for the previously split out function to set the
values from the loaded configuration to the agent/controller fields.

Signed-off-by: Michael Engel <mengel@redhat.com>
Two leaks are fixed:
- agent_unref did not free the peer_socket_options
- unit_infos was allocated twice

Signed-off-by: Michael Engel <mengel@redhat.com>
Signed-off-by: Michael Engel <mengel@redhat.com>
@engelmi engelmi force-pushed the split-up-parse-config-function branch from df15764 to 71662b0 Compare February 14, 2024 10:09
Copy link
Member

@mwperina mwperina left a comment

Choose a reason for hiding this comment

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

LGTM

@engelmi
Copy link
Member Author

engelmi commented Feb 14, 2024

There is still an error in the coverage collection causing it to drop - we are on it.
Merging.

@engelmi engelmi merged commit 06ca91f into eclipse-bluechi:main Feb 14, 2024
19 of 20 checks passed
@engelmi engelmi deleted the split-up-parse-config-function branch February 28, 2024 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants