-
Notifications
You must be signed in to change notification settings - Fork 1
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
Tidies up the uci_wrt.c
file
#235
Conversation
Removes a bunch of duplicated error handling branches by adding the new functions `uwrt_set_properties()` and `uwrt_set_list_properties()`, which call `uwrt_set_[list_]property()` in a loop.
Moves it next to `uwrt_delete_property()` and adds some doxygen doc string.
Simplify uci_wrt.c code by using `uwrt_delete_properties()`
snprintf is a bit more secure, as it will help prevent buffer overflows.
The function `uwrt_delete_properties()` always returns 0, as it ignores all errors. Because of this, we should make it return `void`, since checking the return value is pointless.
Basically just calls all the public firewall functions and checks if they return 0.
Codecov Report
@@ Coverage Diff @@
## main #235 +/- ##
=======================================
Coverage ? 47.90%
=======================================
Files ? 110
Lines ? 16206
Branches ? 0
=======================================
Hits ? 7764
Misses ? 8442
Partials ? 0
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it still in the draft mode?
Now that #234 is merged, I'll open it up as ready! |
Draft until #234 is merged.Tidies up the
uci_wrt.c
file.I've added two new functions:
uwrt_set_properties()
uwrt_add_list_properties()
They look like the following:
Essentially, they just call
uwrt_set_property
/uwrt_add_list_property
multiple times.This means:
(I don't think the compiler is smart enough to optimise utarray loops)
I've also quickly added a simple test for
uci_wrt
, just to confirm that my changes don't cause any errors.