Skip to content

Commit

Permalink
chore: Add more logging to loading conferences from savedata.
Browse files Browse the repository at this point in the history
Better error messages than "something went wrong in type 20".
  • Loading branch information
iphydf committed Nov 8, 2023
1 parent 1195271 commit d8d4b83
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions toxcore/Messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -2988,6 +2988,7 @@ static State_Load_Status load_nospam_keys(Messenger *m, const uint8_t *data, uin
load_secret_key(m->net_crypto, data + sizeof(uint32_t) + CRYPTO_PUBLIC_KEY_SIZE);

if (!pk_equal(data + sizeof(uint32_t), nc_get_self_public_key(m->net_crypto))) {
LOGGER_ERROR(m->log, "public key stored in savedata does not match its secret key");
return STATE_LOAD_STATUS_ERROR;
}

Expand Down
4 changes: 4 additions & 0 deletions toxcore/group.c
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,7 @@ static int addpeer(Group_Chats *g_c, uint32_t groupnumber, const uint8_t *real_p

if (peer_index != -1) {
if (!pk_equal(g->group[peer_index].real_pk, real_pk)) {
LOGGER_ERROR(g_c->m->log, "peer public key is incorrect for peer %d", peer_number);
return -1;
}

Expand Down Expand Up @@ -3679,6 +3680,7 @@ static State_Load_Status load_conferences_helper(Group_Chats *g_c, const uint8_t

if (groupnumber == -1) {
// If this fails there's a serious problem, don't bother with cleanup
LOGGER_ERROR(g_c->m->log, "conference creation failed");
return STATE_LOAD_STATUS_ERROR;
}

Expand All @@ -3696,6 +3698,7 @@ static State_Load_Status load_conferences_helper(Group_Chats *g_c, const uint8_t
assert(ret);
}

LOGGER_ERROR(g_c->m->log, "conference loading failed");
return STATE_LOAD_STATUS_ERROR;
}

Expand All @@ -3705,6 +3708,7 @@ static State_Load_Status load_conferences_helper(Group_Chats *g_c, const uint8_t
nullptr, true, false);

if (peer_index == -1) {
LOGGER_ERROR(g_c->m->log, "adding peer %d failed", g->peer_number);
return STATE_LOAD_STATUS_ERROR;
}

Expand Down
2 changes: 1 addition & 1 deletion toxcore/state.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ int state_load(const Logger *log, state_load_cb *state_load_callback, void *oute
}

case STATE_LOAD_STATUS_ERROR: {
LOGGER_ERROR(log, "Error occcured in state file (type: %u).", type);
LOGGER_ERROR(log, "Error occcured in state file (type: 0x%02x).", type);
return -1;
}

Expand Down

0 comments on commit d8d4b83

Please sign in to comment.