Repository navigation
Conversation
victormlg
commented
Nov 9, 2026
- Moved augments loading code to its own file (augments.c)
- Split LoadAugmentsData into ReadAugment.* helper functions
- Split ReadAugment.* functions into helper functions
- Moved shared code between augments.c and cmdb.c into json_data.c
- Fixed crash on non-array class expressions and CanSetClass() leak
| Log(LOG_LEVEL_VERBOSE, | ||
| "Cannot set class %s:%s from augments, already defined from host-specific data", | ||
| ns, class_spec); | ||
| (ns != NULL) ? ns : "default", class_spec); |
There was a problem hiding this comment.
Is this what led you to do the refactoring? Should there be a unit test that exposes the crash? Are there two bugs? a crash and a leak? Or is that describing one issue?
4a1b2be to
b68070a
Compare
|
Please format the policy files :) |
|
Wait, I will try something first |
|
I will re-review with |
larsewi
left a comment
There was a problem hiding this comment.
Thanks for refactoring. The diff is unreadable, so I've just went though it quickly. In the future it might be a good idea to break it up a bit more. E.g., extract one function out of the 500 line function, one at the time. Then it's easy for a human to verify that this is what is actually being done.
It's nice that you kept bug fixes out of the refactor commits 🚀 However, these should have a changelog entry.
I did some bash mangling and saw that the code move was very clean and direct. I made a comment about this but I guess it was hidden by the time you reviewed. Anyway you go I think this is a challenging transition to make clear and easy. |
Moved from generic_agent.[ch] to augments.[ch], code unchanged. First step towards splitting it up and sharing code with cmdb.c. Ticket: CFE-3658 Signed-off-by: Victor Moene <victor.moene@northern.tech>
LoadAugmentsData() was a single ~500 line function handling all keys inline. One function per top-level key, mirroring cmdb.c, makes it readable and allows sharing code with cmdb.c in the following commits. Ticket: CFE-3658 Signed-off-by: Victor Moene <victor.moene@northern.tech>
Removes duplicated code for installing variables and classes. Ticket: CFE-3658 Signed-off-by: Victor Moene <victor.moene@northern.tech>
Both files had near-identical copies of these helpers. Ticket: CFE-3658 Signed-off-by: Victor Moene <victor.moene@northern.tech>
Bug already present on master. Changelog: Title Ticket: CFE-3658 Signed-off-by: Victor Moene <victor.moene@northern.tech>
Bugs already present on master. The leak is only visible with valgrind/ASan. Changelog: Title Ticket: CFE-3658 Signed-off-by: Victor Moene <victor.moene@northern.tech>
It said "augment inputs". Already present on master. Changelog: Title Ticket: CFE-3658 Signed-off-by: Victor Moene <victor.moene@northern.tech>
b68070a to
d2d2e6c
Compare