Fix a memory leak, an assert and an error message#350
Merged
slyon merged 3 commits intocanonical:mainfrom Apr 27, 2023
Merged
Conversation
slyon
suggested changes
Apr 25, 2023
Contributor
slyon
left a comment
There was a problem hiding this comment.
Thanks for spotting and fixing more papercuts!
I put one tiny suggestion inline (up to you if you want it that way!), and one comment about your fix in nm.c which I'd rather like to see fixed at its origin in parse-nm.c.
03a7ff0 to
009c36f
Compare
daniloegea
commented
Apr 25, 2023
slyon
suggested changes
Apr 25, 2023
009c36f to
87414c7
Compare
slyon
reviewed
Apr 26, 2023
Contributor
slyon
left a comment
There was a problem hiding this comment.
Two more inline comments:
- We cannot be sure the
rendereralready got set in theparse.cstage, we need to check that invalidation.cstage, maybe using ahas_backend_settings_nmhelper variable. - We might want to drop the
NetplanBackendSettingsunion all together.backend_settings.networkd.uniondoesn't seem to be used anywhere. Replacing the union by juststruct NetplanNMSettingsshould be ABI-safe IMO.
If the keyfile group.key is malformed, the function g_key_file_set_string() will trigger a critical assertion.
87414c7 to
5062506
Compare
Contributor
Author
|
I moved the wireguard part to another PR (#352). I converted the NetplanBackendSettings union to a struct as suggested, I think it makes sense. |
slyon
approved these changes
Apr 27, 2023
Contributor
slyon
left a comment
There was a problem hiding this comment.
Thank you very much, this is looking good now!
Just two little nitpicks, maybe you can squash them into their relevant commits, so we can merge this PR with a clean history:
- nitpick: nm.c:write_fallback_key_value() "backend_settings.nm.passthrough" in comment should be adopted, too.
- See inline comment
E.g.:
diff --git a/src/nm.c b/src/nm.c
index 112e1ff6..1d90e54b 100644
--- a/src/nm.c
+++ b/src/nm.c
@@ -517,7 +517,7 @@ write_vxlan_parameters(const NetplanNetDefinition* def, GKeyFile* kf)
/**
* Special handling for passthrough mode: read key-value pairs from
- * "backend_settings.nm.passthrough" and inject them into the keyfile as-is.
+ * "backend_settings.passthrough" and inject them into the keyfile as-is.
*/
static void
write_fallback_key_value(GQuark key_id, gpointer value, gpointer user_data)
diff --git a/src/validation.c b/src/validation.c
index e159a7c2..c87d7f67 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -413,7 +413,7 @@ validate_netdef_grammar(const NetplanParser* npp, NetplanNetDefinition* nd, GErr
backend = npp->global_backend;
if (nd->has_backend_settings_nm && backend != NETPLAN_BACKEND_NM) {
- return yaml_error(npp, NULL, error, "%s: networkmanager.passthrough settings found but renderer is not NetworkManager.", nd->id);
+ return yaml_error(npp, NULL, error, "%s: networkmanager backend settings found but renderer is not NetworkManager.", nd->id);
}
valid = TRUE;If the definition has NetworkManager custom settings, validate if NetworkManager is used as renderer. A new netdef fields was defined, has_backend_settings_nm, to keep track if custom NetworkManager settings were found during parsing.
The networkd settings found in the union NetplanBackendSettings is not used anywhere. Removing it and converting the union into a struct shouldn't change the memory layout as we are keeping the bigger part of it.
5062506 to
432c6ca
Compare
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
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.
Description
Checklist
make checksuccessfully.make check-coverage).