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?
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. 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. Ticket: CFE-3658 Signed-off-by: Victor Moene <victor.moene@northern.tech>
It said "augment inputs". Already present on master. Ticket: CFE-3658 Signed-off-by: Victor Moene <victor.moene@northern.tech>
4a1b2be to
b68070a
Compare
|
Please format the policy files :) |
| @@ -0,0 +1,783 @@ | |||
| /* | |||
| Copyright 2024 Northern.tech AS | |||
| @@ -0,0 +1,38 @@ | |||
| /* | |||
| Copyright 2024 Northern.tech AS | |||
| @@ -22,6 +22,29 @@ | |||
| included file COSL.txt. | |||
| */ | |||
There was a problem hiding this comment.
Please take out one function at the time. Otherwise the diff will be unreadable.
|
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.
| continue; | ||
| } | ||
|
|
||
| /* NULL_JSON() above also treats a JSON null as not specified */ |
There was a problem hiding this comment.
This commit deserves a changelog