-
Notifications
You must be signed in to change notification settings - Fork 67
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
Optimize namespace node and topic validation #130
Conversation
It looks like the string returned was changed from "X is valid" to My guess is that this "matches" a return code of 0 when it succeeds, allowing you to easily know that it went well without having to do costly string operations. If this was the motivation I would recommend returning "unknown X validation result" in the default case rather than changing the return value when the topic/node/namespace name is valid. Good catch for the use of the wrong function in the namspace tests 👍 |
Doing a quick, dirty audit of the callers, it seems like almost none of them expect NULL to be returned from the |
yes, I opt to unify all the specific error string in |
@wjwwood @mikaelarguedas The NULL return is removed and unify the result sting therein, and the relevant adaption required in the components which are affected by it are referenced, please review and give your comments, thanks ! |
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.
Thanks @gaoethan for iterating.
I'll leave @wjwwood a chance to comment on #130 (comment) before reviewing this and related PRs.
I still think that having to do string comparison instead of checking for NULL is pretty expensive and would prefer to have NULL returned for the valid cases,
@@ -47,7 +47,8 @@ TEST(test_validate_topic_name, valid_topic) { | |||
ASSERT_EQ(RMW_RET_OK, ret); | |||
ASSERT_EQ(RMW_TOPIC_VALID, validation_result); | |||
|
|||
ASSERT_EQ((char *)NULL, rmw_full_topic_name_validation_result_string(validation_result)); | |||
ret = strcmp("valid topic name", rmw_full_topic_name_validation_result_string(validation_result)); |
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.
ret is of type rmw_ret_t
that may or may not be an int in the future. I'd recommend using
ASSERT_STREQ("valid topic name", rmw_full_topic_name_validation_result_string(validation_result));
instead. (same in all tests using strcmp).
Agreed. -1 to string comparison. You could instead have it return a ret code and pass a cstring pointer in to be filled with the result. But it should be possible without string comparison to know if a valid string was passed. |
actually, I also think it's a little heavy to compare with the specific string, so I agree with you to return NULL for valid case. however:
|
@ros2/team, any new comments ? I can tweak it if there is to avoid its pending 😄 thanks ! |
sorry for the delay @gaoethan I'll review this and the corresponding PRs in the next |
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.
lgtm, thanks @gaoethan
I just reviewed these. Once last comments are addressed we'll need to rerun CI on this set of PRs before merging |
@gaoethan can you please rebase the branches of all these PRs? as we changed some things in the rmw API this cannot be built / tested on CI without being rebased |
@mikaelarguedas All have already been rebased, and you can go ahead now, :) thanks ! |
make the valid result more accurate, which should be different from the default NULL use rmw_namespace_validation_result_string instead for namespace validation Signed-off-by: Ethan Gao <ethan.gao@linux.intel.com>
and twaek the tests accordingly Signed-off-by: Ethan Gao <ethan.gao@linux.intel.com>
Signed-off-by: Ethan Gao <ethan.gao@linux.intel.com>
Signed-off-by: Ethan Gao <ethan.gao@linux.intel.com>
thanks @gaoethan for iterating, here's a round of ci on this set of PRs |
@mikaelarguedas it seems that CI has passed, should it be merged now ? thanks. |
Thanks @wjwwood I'll merge the connected PRs as well then |
Oh, sorry I missed that there were connected pr's. Thanks. |
Make the result reflection more accurate, which should be
different from the default
NULL
Use
rmw_namespace_validation_result_string
insteadfor namespace validation
Signed-off-by: Ethan Gao ethan.gao@linux.intel.com