-
Notifications
You must be signed in to change notification settings - Fork 284
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: extract each case in handle packet in messenger #2329
refactor: extract each case in handle packet in messenger #2329
Conversation
7077d58
to
07fb5ff
Compare
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.
Functioning
Codecov Report
@@ Coverage Diff @@
## master #2329 +/- ##
==========================================
+ Coverage 78.91% 78.92% +0.01%
==========================================
Files 127 127
Lines 24078 24109 +31
==========================================
+ Hits 19002 19029 +27
- Misses 5076 5080 +4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
cda18b8
to
58e250a
Compare
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.
Reviewable status: 0 of 1 approvals obtained (waiting on @Green-Sky)
toxcore/Messenger.c
line 1942 at r1 (raw file):
non_null(1, 3) nullable(5) static int m_handle_packet_offline(Messenger *m, const int i, const uint8_t *data, const uint16_t data_length, void *userdata)
This function can be simplified:
Code snippet:
if (clause) {
do_thing();
}
return 0;
toxcore/Messenger.c
line 2271 at r1 (raw file):
switch (packet_id) { // TODO(Green-Sky): now all return 0 on error AND success, make errors errors?
This was the case to begin with, best to leave it as-is for now.
toxcore/Messenger.c
line 2298 at r1 (raw file):
} return m_handle_custom_lossless_packet(object, i, temp, len, userdata);
Should this go under a default case? Logically makes no difference but I think it might be cleaner.
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.
Reviewable status: 0 of 1 approvals obtained (waiting on @JFreegman)
toxcore/Messenger.c
line 1942 at r1 (raw file):
Previously, JFreegman wrote…
This function can be simplified:
what is this packet for anyway?
toxcore/Messenger.c
line 2271 at r1 (raw file):
Previously, JFreegman wrote…
This was the case to begin with, best to leave it as-is for now.
yes, that's why i put this TODO
toxcore/Messenger.c
line 2298 at r1 (raw file):
Previously, JFreegman wrote…
Should this go under a default case? Logically makes no difference but I think it might be cleaner.
but then we cant have a final return 0;
at the end of the function. imo it looks better like this, but that's personal preference.
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.
Reviewable status: complete! 1 of 1 approvals obtained (waiting on @Green-Sky)
toxcore/Messenger.c
line 1942 at r1 (raw file):
Previously, Green-Sky (Erik Scholz) wrote…
what is this packet for anyway?
It's self-explanatory if you follow the call stack
toxcore/Messenger.c
line 2298 at r1 (raw file):
Previously, Green-Sky (Erik Scholz) wrote…
but then we cant have a final
return 0;
at the end of the function. imo it looks better like this, but that's personal preference.
Yeah I suppose that's true.
58e250a
to
1a1de89
Compare
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.
Reviewable status: complete! 1 of 1 approvals obtained (waiting on @Green-Sky and @JFreegman)
toxcore/Messenger.c
line 2298 at r1 (raw file):
Previously, JFreegman wrote…
Yeah I suppose that's true.
Done.
1a1de89
to
d3819b2
Compare
alternative / continuation of #2328 using
case: return
to satisfy cimpleThis change is