-
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
refactor: fix const char * warnings #239
Conversation
Codecov Report
@@ Coverage Diff @@
## main #239 +/- ##
==========================================
+ Coverage 47.89% 48.53% +0.64%
==========================================
Files 110 113 +3
Lines 17828 16264 -1564
==========================================
- Hits 8539 7894 -645
+ Misses 9289 8370 -919
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Converts some `char *` arrays into `const char *` arrays to fix compiler invalid const qualifier discardation errors. E.g. converts: `char * example[] = {...};` to `const char *` This also may fix a thread-safety bug in `ipaddr_modify()`. `get_prefix()` modifies the input string temporarily. However, even though the function changes the string back the original value, since edgesec uses multithreading, this may have caused an error.
526eeba
to
a4c79f3
Compare
return 0; | ||
} | ||
|
||
static int teardown(void **state) { |
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.
Did you test if the interface is actually removed?
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.
No need :)
I've only added a basic test that checks whether nl_set_interface_ip()
fails if the interface doesn't exist, so there's actually no interface.
I couldn't figure out how to add a test that checks whether it actually works (I'm guessing we'd need to do a bunch of mocks).
expect_function_call(log_error); | ||
expect_string(__wrap_log_levels, error_message, | ||
"nl_set_interface_ip error: ipaddr_modify failed with -1"); | ||
assert_int_equal(nl_set_interface_ip(ptr->context, test_nl_interface_name, |
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.
To complete the test we need to check if the right IP was assigned by using the function nl_get_interfaces
.
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.
The test currently only checks for failure if the interface doesn't exist, so the right IP is never assigned.
I'm not 100% sure how to actually test if this function works (since tests need to run on CI too, and ideally without sudo
access), but I guess it will take a lot of mocks.
Currently just tests that `nl_set_interface_ip()` throws an error that says: ipaddr_modify error: could not find interface 'test_nl_interface_name' for an interface that doesn't exist.
7995a0e
to
4eddcf0
Compare
Converts some
char *
arrays intoconst char *
arrays to fix compiler invalid const qualifier discardation errors.E.g. converts:
char * example[] = {...};
toconst char *
This also may fix a thread-safety bug in
ipaddr_modify()
.get_prefix()
modifies the input string temporarily.However, even though the function changes the string back the original value, since edgesec uses multithreading, this may have caused an error.