Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/request_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <string.h>

#include <libsettings/settings.h>
#include <swiftnav/logging.h>

#include <internal/request_state.h>
#include <internal/setting_def.h>
Expand Down Expand Up @@ -95,7 +96,12 @@ bool request_state_match(const request_state_t *state) {
int request_state_signal(request_state_t *state, settings_api_t *api,
uint16_t msg_id) {
assert(state);
assert(msg_id == state->msg_id);

if (msg_id != state->msg_id) {
log_error("Error: request msg_id [%d] do not match state msg_id [%d]",
msg_id, state->msg_id);
assert(!"request msg_id do not match state msg_id");
}

state->match = true;
state->pending = false;
Expand Down
2 changes: 1 addition & 1 deletion src/setting_sbp_cb.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ static void setting_read_by_index_done_callback(uint16_t sender_id, uint8_t len,

/* Traverse the pending requests */
request_state_t *state = ctx->req_list;
while (state != NULL) {
while (state != NULL && state->msg_id == SBP_MSG_SETTINGS_READ_BY_INDEX_REQ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should leave the while loop alone and add an if (state->msg_id == SBP_MSG_SETTINGS_READ_BY_INDEX_REQ) for request_state_signal.

We still need the while loop to call state = state->next;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will consume all the remaining states. Is that expected?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not 100% sure. I do not know the original intention of this code block, but from the comments it seems like that is the intention, to /* Traverse the pending requests */.

state->read_by_idx_done = true;
request_state_signal(state, &ctx->client_iface,
SBP_MSG_SETTINGS_READ_BY_INDEX_REQ);
Expand Down