refactor: extract each case in handle packet in messenger - #2329
Conversation
7077d58 to
07fb5ff
Compare
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
JFreegman
left a comment
There was a problem hiding this comment.
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.
Green-Sky
left a comment
There was a problem hiding this comment.
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.
JFreegman
left a comment
There was a problem hiding this comment.
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
Green-Sky
left a comment
There was a problem hiding this comment.
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: returnto satisfy cimpleThis change is