Fix the types used in token counts.
The number of tokens is inconsistent throughout the API. max_batchsize
is a uint16_t. max_issuance is a size_t. out_tokens_issued is a
uint8_t*. The serialization only supports up to uint16_t.
Standardize on size_t. The natural size for a count of elements is
size_t. Protocol limitations can be handled within the implementation.
Additionally, it is best not to use small types for counters in public
APIs in C/C++ because the language has implicit truncating conversions.
(Whereas code points or other enum-like values are fine because the
caller won't managed to get a 32-bit cipher suite.)
Update-Note: Fix callers of TRUST_TOKEN_ISSUER_issue to use size_t
instead of uint8_t. The max_batchsize changes should go through without
changes to the caller.
Change-Id: I9be5dd8f61abdbe5a1dbe70b8dc72d06114b1022
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/41044
Commit-Queue: Steven Valdez <svaldez@google.com>
Reviewed-by: Steven Valdez <svaldez@google.com>
diff --git a/tool/speed.cc b/tool/speed.cc
index c91c25b..b1f530d 100644
--- a/tool/speed.cc
+++ b/tool/speed.cc
@@ -1109,8 +1109,7 @@
if (!TimeFunction(&results, [&]() -> bool {
uint8_t *issue_resp = NULL;
- size_t resp_len;
- uint8_t tokens_issued;
+ size_t resp_len, tokens_issued;
int ok = TRUST_TOKEN_ISSUER_issue(issuer.get(), &issue_resp, &resp_len,
&tokens_issued, issue_msg, msg_len,
/*public_metadata=*/0,
@@ -1125,8 +1124,7 @@
results.Print(name + " issue");
uint8_t *issue_resp = NULL;
- size_t resp_len;
- uint8_t tokens_issued;
+ size_t resp_len, tokens_issued;
if (!TRUST_TOKEN_ISSUER_issue(issuer.get(), &issue_resp, &resp_len,
&tokens_issued, issue_msg, msg_len,
/*public_metadata=*/0, /*private_metadata=*/0,