Skip to content

Commit 056bf1f

Browse files
committed
Feedback
1 parent 1d29b4f commit 056bf1f

9 files changed

+19
-26
lines changed

src/mc-fle2-find-equality-payload-v2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void mc_FLE2FindEqualityPayloadV2_cleanup(mc_FLE2FindEqualityPayloadV2_t *payloa
4747

4848
#define PARSE_BINARY(Name, Dest) \
4949
IF_FIELD(Name) { \
50-
if (!parse_bindata(#Name, BSON_SUBTYPE_BINARY, &iter, &out->Dest, status)) { \
50+
if (!parse_bindata(BSON_SUBTYPE_BINARY, &iter, &out->Dest, status)) { \
5151
goto fail; \
5252
} \
5353
} \

src/mc-fle2-find-equality-payload.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void mc_FLE2FindEqualityPayload_cleanup(mc_FLE2FindEqualityPayload_t *payload) {
4848

4949
#define PARSE_BINARY(Name, Dest) \
5050
IF_FIELD(Name) { \
51-
if (!parse_bindata(#Name, BSON_SUBTYPE_BINARY, &iter, &out->Dest, status)) { \
51+
if (!parse_bindata(BSON_SUBTYPE_BINARY, &iter, &out->Dest, status)) { \
5252
goto fail; \
5353
} \
5454
} \

src/mc-fle2-find-text-payload.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
#define PARSE_BINARY(Name, Dest) \
4545
IF_FIELD(Name) { \
46-
if (!parse_bindata(#Name, BSON_SUBTYPE_BINARY, &iter, Dest, status)) { \
46+
if (!parse_bindata(BSON_SUBTYPE_BINARY, &iter, Dest, status)) { \
4747
goto fail; \
4848
} \
4949
} \
@@ -137,7 +137,6 @@ static bool mc_TextFindTokenSetIndirection_parse(mc_TextFindTokenSetIndirection_
137137

138138
return true;
139139
fail:
140-
mc_TextFindTokenSetIndirection_cleanup(out);
141140
return false;
142141
}
143142

@@ -371,7 +370,6 @@ bool mc_FLE2FindTextPayload_parse(mc_FLE2FindTextPayload_t *out, const bson_t *i
371370
CHECK_HAS(df);
372371
return true;
373372
fail:
374-
mc_FLE2FindTextPayload_cleanup(out);
375373
return false;
376374
}
377375

src/mc-fle2-insert-update-payload-v2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void mc_FLE2InsertUpdatePayloadV2_cleanup(mc_FLE2InsertUpdatePayloadV2_t *payloa
134134

135135
#define PARSE_BINDATA(Name, Type, Dest) \
136136
IF_FIELD(Name) { \
137-
if (!parse_bindata(#Name, Type, &iter, &out->Dest, status)) { \
137+
if (!parse_bindata(Type, &iter, &out->Dest, status)) { \
138138
goto fail; \
139139
} \
140140
} \

src/mc-fle2-insert-update-payload.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void mc_FLE2InsertUpdatePayload_cleanup(mc_FLE2InsertUpdatePayload_t *payload) {
7070

7171
#define PARSE_BINDATA(Name, Type, Dest) \
7272
IF_FIELD(Name) { \
73-
if (!parse_bindata(#Name, Type, &iter, &out->Dest, status)) { \
73+
if (!parse_bindata(Type, &iter, &out->Dest, status)) { \
7474
goto fail; \
7575
} \
7676
} \

src/mc-parse-utils-private.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@
2222
/* Validates that the given bson_iter_t points to bindata element, with
2323
* the given subtype. If so, it copies the binary data to @out and returns true.
2424
* If validation fails, then it returns false and sets an error in @status.*/
25-
bool parse_bindata(const char *field_name,
26-
bson_subtype_t subtype,
27-
bson_iter_t *iter,
28-
_mongocrypt_buffer_t *out,
29-
mongocrypt_status_t *status);
25+
bool parse_bindata(bson_subtype_t subtype, bson_iter_t *iter, _mongocrypt_buffer_t *out, mongocrypt_status_t *status);
3026

3127
#endif /* MC_PARSE_UTILS_PRIVATE_H */

src/mc-parse-utils.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
#include "mongocrypt-private.h"
1919
#include "mongocrypt-util-private.h"
2020

21-
bool parse_bindata(const char *field_name,
22-
bson_subtype_t subtype,
23-
bson_iter_t *iter,
24-
_mongocrypt_buffer_t *out,
25-
mongocrypt_status_t *status) {
21+
bool parse_bindata(bson_subtype_t subtype, bson_iter_t *iter, _mongocrypt_buffer_t *out, mongocrypt_status_t *status) {
22+
BSON_ASSERT_PARAM(iter);
23+
BSON_ASSERT_PARAM(out);
24+
2625
bson_subtype_t parsed_subtype;
2726
uint32_t len;
2827
const uint8_t *data;
28+
const char *field_name = bson_iter_key(iter);
2929
if (bson_iter_type(iter) != BSON_TYPE_BINARY) {
3030
CLIENT_ERR("Field '%s' expected to be bindata, got: %s",
3131
field_name,

src/mongocrypt-buffer.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ int _mongocrypt_buffer_cmp(const _mongocrypt_buffer_t *a, const _mongocrypt_buff
260260
void _mongocrypt_buffer_cleanup(_mongocrypt_buffer_t *buf) {
261261
if (buf && buf->owned) {
262262
bson_free(buf->data);
263-
buf->data = NULL;
264263
}
265264
}
266265

test/test-mc-fle2-find-text-payload.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ static void _validate_parsed_payload(_mongocrypt_tester_t *tester,
5353
}
5454

5555
if (parsed->substringSpec.set) {
56-
ASSERT(parsed->substringSpec.value.lb == expected->substringSpec.value.lb);
57-
ASSERT(parsed->substringSpec.value.ub == expected->substringSpec.value.ub);
58-
ASSERT(parsed->substringSpec.value.mlen == expected->substringSpec.value.mlen);
56+
ASSERT_CMPUINT32(parsed->substringSpec.value.lb, ==, expected->substringSpec.value.lb);
57+
ASSERT_CMPUINT32(parsed->substringSpec.value.ub, ==, expected->substringSpec.value.ub);
58+
ASSERT_CMPUINT32(parsed->substringSpec.value.mlen, ==, expected->substringSpec.value.mlen);
5959
}
6060
if (parsed->suffixSpec.set) {
61-
ASSERT(parsed->suffixSpec.value.lb == expected->suffixSpec.value.lb);
62-
ASSERT(parsed->suffixSpec.value.ub == expected->suffixSpec.value.ub);
61+
ASSERT_CMPUINT32(parsed->suffixSpec.value.lb, ==, expected->suffixSpec.value.lb);
62+
ASSERT_CMPUINT32(parsed->suffixSpec.value.ub, ==, expected->suffixSpec.value.ub);
6363
}
6464
if (parsed->prefixSpec.set) {
65-
ASSERT(parsed->prefixSpec.value.lb == expected->prefixSpec.value.lb);
66-
ASSERT(parsed->prefixSpec.value.ub == expected->prefixSpec.value.ub);
65+
ASSERT_CMPUINT32(parsed->prefixSpec.value.lb, ==, expected->prefixSpec.value.lb);
66+
ASSERT_CMPUINT32(parsed->prefixSpec.value.ub, ==, expected->prefixSpec.value.ub);
6767
}
6868
}
6969

@@ -110,7 +110,7 @@ static const char *k_svrToken = "8773322a2b9e6c08886db6bc65b46ffdd64651e8a49400a
110110
// Tests mc_FLE2FindTextPayload_serialize() works correctly, and non-error cases
111111
// for mc_FLE2FindTextPayload_parse().
112112
static void _test_FLE2FindTextPayload_roundtrip(_mongocrypt_tester_t *tester) {
113-
// Test exact token set + no specs present
113+
// Test exact token set + prefix spec present
114114
{
115115
mc_FLE2FindTextPayload_t payload;
116116
mc_FLE2FindTextPayload_init(&payload);

0 commit comments

Comments
 (0)