Skip to content
Merged
Changes from all 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
4 changes: 3 additions & 1 deletion src/modules/extrakeys/tests_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,9 @@ static void test_sort(void) {
}
secp256k1_pubkey_sort(CTX, pk_ptr, 5);
for (j = 1; j < 5; j++) {
CHECK(secp256k1_pubkey_sort_cmp(&pk_ptr[j - 1], &pk_ptr[j], CTX) <= 0);
secp256k1_pubkey_sort_cmp_data cmp_data;
Copy link
Contributor

Choose a reason for hiding this comment

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

I confirmed that declaring the cmp_data variable at the beginning of the function does not cause any issues. This means we do not need to create a new instance for each iteration.

I reviewed the secp256k1_pubkey_sort_cmp function, and it appears that the ctx variable is not utilized within the secp256k1_pubkey_load function. My understanding of this usage is limited, so please correct me if I am mistaken.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's correct that ctx is never used (which is why the old, incorrect code could pass the tests).

As for scoping, IMO we should keep cmp_data as tightly scoped as we can, because it makes the code easier to read.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it, thanks!

cmp_data.ctx = CTX;
CHECK(secp256k1_pubkey_sort_cmp(&pk_ptr[j - 1], &pk_ptr[j], &cmp_data) <= 0);
}
}
}
Expand Down
Loading