Make saving and loading the responsibility of Tox rather than Messenger#1213
Conversation
There was a problem hiding this comment.
Perhaps while you're changing this code already, remove the vla and use malloc/free?
f1c0e13 to
9038ec4
Compare
Codecov Report
@@ Coverage Diff @@
## master #1213 +/- ##
========================================
- Coverage 83.1% 83% -0.1%
========================================
Files 82 82
Lines 14694 14683 -11
========================================
- Hits 12218 12196 -22
- Misses 2476 2487 +11
Continue to review full report at Codecov.
|
b50824f to
4d084e7
Compare
|
I factored the save invariance and associated tests out as a separate
PR, #1215.
|
There was a problem hiding this comment.
Replace !num with num == 0 when num is an integer, not a bool. Also, would it make sense to return -1 on the inverted condition, considering it an error return, and returning the success/failure of state_load at the end of the function?
There was a problem hiding this comment.
Why did you rename savedata to data? Now the .c and .h files are out of sync. If you want to use the name "data" in the function, you can assign savedata to data (which may not be such a bad idea anyway, since it avoids assigning to parameters).
iphydf
left a comment
There was a problem hiding this comment.
I need to leave a comment, I can't just put comments on the code without also putting a comment in this box, so here is a comment. Thanks Github.
|
Can you rebase or merge upstream/master? |
|
* Tuesday, 2018-10-16 at 15:23 -0700 - iphydf <notifications@github.com>:
Can you rebase or merge upstream/master?
Done
|
iphydf
left a comment
There was a problem hiding this comment.
Reviewable status: 1 change requests, 0 of 1 approvals obtained (waiting on @zugz)
auto_tests/messenger_test.c, line 268 at r3 (raw file):
END_TEST /* This test is disabled, because saving is now handled by Tox rather than Messenger. */
Is there value in keeping this test around but commented out? Are you planning to delete or revive it in the future?
testing/Messenger_test.c, line 137 at r3 (raw file):
} /* Loading disabled, because loading is now handled by Tox rather than Messenger */
Should this also be deleted instead of commented out?
toxcore/group.h, line 457 at r1 (raw file):
Previously, iphydf wrote…
/** * Load a section. * * @...
Done. (comment on behalf of zugz)
toxcore/state.h, line 25 at r3 (raw file):
#define TOP_STATE_COOKIE_TYPE 0x01ce typedef enum Top_State_Type {
State_Type, otherwise it's not in the module namespace of module "state", but instead in the namespace of module "top", which we don't have.
Separately, this is not a great place for this enum to live, but I don't have a better suggestion, so let's keep it here for now.
toxcore/state.c, line 109 at r1 (raw file):
Previously, zugz (zugz) wrote…
Hmm... I wouldn't know how best to do it, and I understand we intend to redo saving completely eventually. So I'd rather defer.
Ok, the way you do it is by serialising the integer instead of memcpying it into a byte array. I'm fine with deferring.
toxcore/tox.c, line 368 at r2 (raw file):
Previously, iphydf wrote…
Replace
!numwithnum == 0whennumis an integer, not a bool. Also, would it make sense to return -1 on the inverted condition, considering it an error return, and returning the success/failure of state_load at the end of the function?
Done (comment on behalf of zugz).
toxcore/tox.c, line 604 at r2 (raw file):
Previously, iphydf wrote…
Why did you rename savedata to data? Now the .c and .h files are out of sync. If you want to use the name "data" in the function, you can assign savedata to data (which may not be such a bad idea anyway, since it avoids assigning to parameters).
Done (comment on behalf of zugz).
auto_tests/save_load_test.c, line 100 at r1 (raw file):
Previously, iphydf wrote…
Perhaps while you're changing this code already, remove the vla and use malloc/free?
Done (in separate PR).
|
* Wednesday, 2018-10-17 at 05:17 -0700 - iphydf <notifications@github.com>:
*[testing/Messenger_test.c, line 137 at r3](https://reviewable.io/reviews/toktok/c-toxcore/1213#-LP0w4_o8qCfdpnPxHUy:-LP0w4_o8qCfdpnPxHUz:bqszos9) ([raw file](https://github.com/toktok/c-toxcore/blob/7f90dca13d91a2e47f859f31a29dc12056e7f40a/testing/Messenger_test.c#L137)):*
> ```C
> }
>
> /* Loading disabled, because loading is now handled by Tox rather than Messenger */
> ```
Should this also be deleted instead of commented out?
I'd rather leave it, in case someone one day wants to adapt it.
Done the rest. I can fire up reviewables to say so there if that would
really be helpful.
I looked again, and the loading code in Messenger_test is trivial enough that actually I don't think there's much point keeping it around. I've deleted it now.
|
iphydf
left a comment
There was a problem hiding this comment.
Reviewable status: 1 change requests, 0 of 1 approvals obtained
auto_tests/messenger_test.c, line 268 at r3 (raw file):
Previously, iphydf wrote…
Is there value in keeping this test around but commented out? Are you planning to delete or revive it in the future?
Done (comment on behalf of zugz).
testing/Messenger_test.c, line 137 at r3 (raw file):
Previously, zugz (zugz) wrote…
- Wednesday, 2018-10-17 at 05:17 -0700 - iphydf notifications@github.com:
testing/Messenger_test.c, line 137 at r3 (raw file): >
C > } > > /* Loading disabled, because loading is now handled by Tox rather than Messenger */ >Should this also be deleted instead of commented out?
I'd rather leave it, in case someone one day wants to adapt it.
Done the rest. I can fire up reviewables to say so there if that would really be helpful. I looked again, and the loading code in Messenger_test is trivial enough that actually I don't think there's much point keeping it around. I've deleted it now.
Done (comment on behalf of zugz).
toxcore/state.h, line 25 at r3 (raw file):
Previously, iphydf wrote…
State_Type, otherwise it's not in the module namespace of module "state", but instead in the namespace of module "top", which we don't have.Separately, this is not a great place for this enum to live, but I don't have a better suggestion, so let's keep it here for now.
Done (comment on behalf of zugz).
This change is