Skip to content

Commit b9eaec6

Browse files
committed
Move exclusive ub into helper
1 parent 1526054 commit b9eaec6

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/mongocrypt-marking.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -729,15 +729,17 @@ static bool _mongocrypt_fle2_placeholder_common(_mongocrypt_key_broker_t *kb,
729729
}
730730

731731
static bool _fle2_choose_contention_factor(mongocrypt_t *crypt,
732-
int64_t exclusive_upper_bound,
732+
int64_t maxContentionFactor,
733733
int64_t *out,
734734
mongocrypt_status_t *status) {
735+
BSON_ASSERT_PARAM(crypt);
736+
BSON_ASSERT_PARAM(out);
735737
if (crypt->opts.contention_factor_fn) {
736-
if (!crypt->opts.contention_factor_fn(exclusive_upper_bound, out)) {
738+
if (!crypt->opts.contention_factor_fn(maxContentionFactor + 1, out)) {
737739
CLIENT_ERR("contention_factor_fn failed");
738740
return false;
739741
}
740-
if (*out < 0 || *out > exclusive_upper_bound) {
742+
if (*out < 0 || *out > maxContentionFactor) {
741743
CLIENT_ERR("chosen contentionFactor out of range");
742744
return false;
743745
}
@@ -771,7 +773,7 @@ static bool _mongocrypt_fle2_placeholder_to_insert_update_common(_mongocrypt_key
771773
/* Choose a contentionFactor in the inclusive range [0,
772774
* placeholder->maxContentionFactor] */
773775
if (!_fle2_choose_contention_factor(kb->crypt,
774-
placeholder->maxContentionFactor + 1,
776+
placeholder->maxContentionFactor,
775777
&out->contentionFactor,
776778
status)) {
777779
goto fail;
@@ -1570,7 +1572,7 @@ static bool _mongocrypt_fle2_placeholder_to_insert_update_ciphertextForTextSearc
15701572
/* Choose a contentionFactor in the inclusive range [0,
15711573
* placeholder->maxContentionFactor] */
15721574
if (!_fle2_choose_contention_factor(kb->crypt,
1573-
placeholder->maxContentionFactor + 1,
1575+
placeholder->maxContentionFactor,
15741576
&payload.contentionFactor,
15751577
status)) {
15761578
goto fail;

0 commit comments

Comments
 (0)