-
Notifications
You must be signed in to change notification settings - Fork 286
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
Make conferences persist across restarts #295
Conversation
Review status: 0 of 10 files reviewed at latest revision, 2 unresolved discussions, some commit checks failed. toxcore/group.c, line 32 at r1 (raw file):
would be better to use C99 standard types here as in the rest of the code toxcore/group.c, line 421 at r1 (raw file):
same Comments from Reviewable |
e8522a3
to
4d14a49
Compare
Review status: 0 of 10 files reviewed at latest revision, 2 unresolved discussions, some commit checks failed. toxcore/group.c, line 32 at r1 (raw file): Previously, sudden6 wrote…
Working on it. There are a ton of toxcore/group.c, line 421 at r1 (raw file): Previously, sudden6 wrote…
Done. Comments from Reviewable |
toxcore/group.c
Outdated
{ | ||
if ((unsigned)groupnumber >= g_c->num_chats) { | ||
if (groupnumber == -1 || groupnumber >= g_c->num_chats) { |
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.
Semantics changed: previously it was < 0
.
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.
Done.
@robinlinden can you squash all your commits, so I can see whether your changes are correct? Also, is this PR ready for review? You don't need to make it perfect before review. The idea was that we would take the code as-is, and collaboratively improve it through several rounds of review. Your task is just to evaluate and make the changes requested by the reviewers (one of which may be also you, but we should discuss the changes even if you make them). |
a54f466
to
6143b01
Compare
toxcore/group.c
Outdated
if (nick_len > peer->nick_len) { | ||
uint8_t *new_nick = realloc(peer->nick, nick_len + 1); | ||
|
||
if (!new_nick) { | ||
return 0; | ||
return false; |
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.
I made a logic change here. Previously the function returned success if it couldn't allocate space for a new nickname.
It is ready for review. Most of what I've done has been removing aints and replacing them with other suitable types. While there are still a lot of them left, this is ready for review. I'll stop making changes without posting comments about it first so we can discuss them. |
Review status: 0 of 10 files reviewed at latest revision, 20 unresolved discussions, some commit checks failed. toxcore/group.c, line 34 at r2 (raw file):
Remove extra spacing after toxcore/group.c, line 41 at r2 (raw file):
Remove empty line. toxcore/group.c, line 54 at r2 (raw file):
toxcore/group.c, line 261 at r3 (raw file):
Create a new function in toxcore/group.c, line 295 at r3 (raw file):
Remove superfluous toxcore/group.c, line 300 at r3 (raw file):
Remove superfluous toxcore/group.c, line 306 at r3 (raw file):
Remove no-op return. toxcore/group.c, line 324 at r3 (raw file):
Above, the type used for something counting towards toxcore/group.c, line 355 at r3 (raw file):
toxcore/group.c, line 392 at r3 (raw file):
This function is 257 lines long. That is too long. Please break it into logical units. toxcore/group.c, line 651 at r3 (raw file):
Move this declaration to the top together with all the other static function declarations. toxcore/group.c, line 653 at r3 (raw file):
Perhaps break this function into two or three. toxcore/group.c, line 665 at r3 (raw file):
toxcore/group.c, line 688 at r3 (raw file):
Another toxcore/group.c, line 782 at r3 (raw file):
toxcore/group.c, line 815 at r3 (raw file):
toxcore/group.c, line 828 at r3 (raw file):
This is definitely wrong. Comments from Reviewable |
Reviewed 8 of 10 files at r1, 2 of 2 files at r2. Comments from Reviewable |
Reviewed 1 of 1 files at r3. Comments from Reviewable |
Review status: all files reviewed at latest revision, 20 unresolved discussions, some commit checks failed. toxcore/group.c, line 34 at r2 (raw file): Previously, iphydf wrote…
I switched these macros over to being functions. Comments from Reviewable |
Review status: all files reviewed at latest revision, 27 unresolved discussions, some commit checks failed. toxcore/group.c, line 191 at r3 (raw file):
What's -2? toxcore/group.c, line 935 at r3 (raw file):
Instead of casting here, make toxcore/group.c, line 2388 at r3 (raw file):
toxcore/group.c, line 2394 at r3 (raw file):
Local variables should be lowercase. toxcore/group.c, line 3973 at r3 (raw file):
While this looks cute, it's slightly confusing to have "functions" mutating variables in the lexical environment. Prefer to make these two functions and calling them like toxcore/group.c, line 3981 at r3 (raw file):
Are we sure this cast and dereference is valid? Is toxcore/group.h, line 55 at r3 (raw file):
Why was this 9 again? I keep forgetting, which means we need a named constant with an explanation as to why it's 9. toxcore/group.h, line 104 at r3 (raw file):
Add a comment about what's in here: the type (what is type?) and uid (32 random bytes). Comments from Reviewable |
Review status: all files reviewed at latest revision, 27 unresolved discussions, some commit checks failed. toxcore/group.c, line 979 at r3 (raw file): Previously, robinlinden (Robin Lindén) wrote…
@isotoxin can you verify that this semantic change is correct? Comments from Reviewable |
Review status: all files reviewed at latest revision, 29 unresolved discussions, some commit checks failed. toxcore/group.c, line 919 at r3 (raw file):
toxcore/group.c, line 1375 at r3 (raw file):
@isotoxin what's the difference between Comments from Reviewable |
Just create define
Copy-paste artefact. No need for this assignment
Old irg's code used "peernumber" for two different entities: peer index and peer id. |
see group_packet_index |
Review status: all files reviewed at latest revision, 54 unresolved discussions, some commit checks failed. toxcore/group.c, line 892 at r3 (raw file):
Remove extra toxcore/group.c, line 895 at r3 (raw file):
Choose a better name than toxcore/group.c, line 909 at r3 (raw file):
This is a 1-bit return value => use bool. toxcore/group.c, line 1226 at r3 (raw file):
Rename all peernumbers to peer_index if they are in fact peer_indices. Not all peernumbers were renamed, so I'm not sure which one should be gid and which should be peer_index. toxcore/group.c, line 1375 at r3 (raw file):
Rename this function to toxcore/group.c, line 1414 at r3 (raw file):
It doesn't return a type, it returns 0 on success. Should it return a type? If not, make it return bool. toxcore/group.c, line 1434 at r3 (raw file):
Can length be negative? If not, it should not be a signed integer type. toxcore/group.c, line 1443 at r3 (raw file):
Remove extra space. toxcore/group.c, line 1456 at r3 (raw file):
Why is friendcon_id an aint now? It's being cast back to int later in this function. toxcore/group.c, line 3074 at r3 (raw file):
Why does every caller of toxcore/group.c, line 3336 at r3 (raw file):
Use toxcore/group.c, line 3441 at r3 (raw file):
This can cause signed integer overflow and thus undefined behaviour. toxcore/group.c, line 3449 at r3 (raw file):
Remove all empty lines after toxcore/group.c, line 3478 at r3 (raw file):
What's 333? toxcore/group.c, line 3487 at r3 (raw file):
What are all these next time numbers? toxcore/group.c, line 3530 at r3 (raw file):
Also remove all empty lines before toxcore/group.c, line 3598 at r3 (raw file):
s/ct/now toxcore/group.c, line 3600 at r3 (raw file):
Who's J.D.? What does the d stand for? toxcore/group.c, line 3604 at r3 (raw file):
min_num (I guess?) toxcore/group.c, line 3738 at r3 (raw file):
Make a constant for this. toxcore/group.c, line 3744 at r3 (raw file):
Oh look, there is 333 again. Make a constant for it. toxcore/group.c, line 3838 at r3 (raw file):
num_chats is uint16_t. toxcore/group.c, line 3846 at r3 (raw file):
toxcore/group.c, line 3865 at r3 (raw file):
Same here. toxcore/group.c, line 3958 at r3 (raw file):
And here. And in other places. Comments from Reviewable |
There are two places where delpeer called. Both of them already checked groupnumber parameter before call. delpeer can be failed only if wrong groupnumber is passed into it. So, due correct groupnumber is passed, no need to check return value.
Omg! Are you serious? This is not problem for next 89 years. Even if the tox will alive after 89 years, this code will work correctly. Just try to understand how this function is used and do not offer stupid notes. |
If delpeer can only ever be called with the correct group number, why does it need to have a check like that at all? Seems more a job for an assert at that point. |
Because every function must check incoming params, isn't it? Security related software... blah blah. You'd be the first person who would insist on this check |
Reviewed 16 of 20 files at r25. auto_tests/conference_test.c, line 60 at r23 (raw file): Previously, iphydf wrote…
I'm ok with with it if it will be declared behaviour. So remove TODO and test case? toxcore/group.h, line 162 at r25 (raw file):
In real toxcore/group.h, line 171 at r25 (raw file):
toxcore/group.h, line 179 at r25 (raw file):
Same as above Comments from Reviewable |
Peer numbers aren't defined anywhere. I assume that they're no different from friend numbers, meaning it's not safe to just iterate 0 through max_peers and assume those are all valid peer numbers (they could be random ID's for all I know). When we join a conference, we receive the dubious event Peernumbers need to be defined and/or provided by the API, and there should be no |
@JFreegman I agree with all that, but fixing it takes a bit of work I don't want us to do before the release. We'll live with this for now, and either fix it in the next release, or have new group chats ready enough by then so we can drop this altogether. |
@robinlinden there are some minor comments left on this PR. Can you take care of them? |
797a9d3
to
24e1e5a
Compare
Review status: 8 of 17 files reviewed at latest revision, 37 unresolved discussions. toxcore/group.c, line 870 at r3 (raw file): Previously, iphydf wrote…
Done. toxcore/group.c, line 2228 at r3 (raw file): Previously, iphydf wrote…
Done. (I think. This comment has been dislocated.) toxcore/group.h, line 162 at r25 (raw file): Previously, Diadlo (Polshakov Dmitry) wrote…
Done. toxcore/group.h, line 171 at r25 (raw file): Previously, Diadlo (Polshakov Dmitry) wrote…
Done. toxcore/group.h, line 179 at r25 (raw file): Previously, Diadlo (Polshakov Dmitry) wrote…
Done. Comments from Reviewable |
d9014de
to
2be16bf
Compare
Reviewed 2 of 21 files at r22, 4 of 20 files at r25, 2 of 11 files at r26. toxcore/group.c, line 2182 at r23 (raw file): Previously, iphydf wrote…
ok toxcore/group.c, line 2687 at r23 (raw file): Previously, iphydf wrote…
ok toxcore/group.c, line 2499 at r24 (raw file): Previously, iphydf wrote…
ok toxcore/group.c, line 500 at r26 (raw file):
error handling if realloc fails? toxcore/group.c, line 576 at r26 (raw file):
optional: invert condition and use toxcore/group.c, line 1906 at r26 (raw file):
invert and use early return to match the general style toxcore/group.c, line 2391 at r26 (raw file):
use Comments from Reviewable |
Review status: 9 of 17 files reviewed at latest revision, 37 unresolved discussions, some commit checks failed. toxcore/group.c, line 576 at r26 (raw file): Previously, sudden6 wrote…
Done. toxcore/group.c, line 1906 at r26 (raw file): Previously, sudden6 wrote…
Done. toxcore/group.c, line 2391 at r26 (raw file): Previously, sudden6 wrote…
Done. Comments from Reviewable |
33251dc
to
590c92d
Compare
590c92d
to
ec31a16
Compare
toxcore/group.c, line 1180 at r28 (raw file):
When Comments from Reviewable |
This is not new groupchats. This is just upgrade to old groupchats with some advantages: - Groupchats are now saved into tox_save. - Clients can get groupchat unique id to save message log. - Auto restore groupchats after restart even your friend uses non-upgraded version.
ec31a16
to
6fa4089
Compare
Please put your review comments on #826. Sorry for the redundancy. This PR is too messy now. |
New PR with @isotoxin's code from #263. The scope of this PR is cleanup.
This change is