3737#include < memcached/types.h>
3838#include < platform/histogram.h>
3939#include < xattr/blob.h>
40+ #include < gsl/gsl>
4041
4142static const std::array<SubdocCmdContext::Phase, 2 > phases{{SubdocCmdContext::Phase::XATTR,
4243 SubdocCmdContext::Phase::Body}};
@@ -67,10 +68,14 @@ static ENGINE_ERROR_CODE subdoc_update(SubdocCmdContext& context,
6768static void subdoc_response (Cookie& cookie, SubdocCmdContext& context);
6869
6970// Debug - print details of the specified subdocument command.
70- static void subdoc_print_command (Connection& c, protocol_binary_command cmd,
71- const char * key, const uint16_t keylen,
72- const char * path, const uint16_t pathlen,
73- const char * value, const uint32_t vallen) {
71+ static void subdoc_print_command (Connection& c,
72+ protocol_binary_command cmd,
73+ const char * key,
74+ const uint16_t keylen,
75+ const char * path,
76+ const size_t pathlen,
77+ const char * value,
78+ const size_t vallen) {
7479 char clean_key[KEY_MAX_LENGTH + 32 ];
7580 char clean_path[SUBDOC_PATH_MAX_LENGTH];
7681 char clean_value[80 ]; // only print the first few characters of the value.
@@ -1406,7 +1411,8 @@ static size_t encode_multi_mutation_result_spec(uint8_t index,
14061411 // Also encode resultlen if status is success.
14071412 if (op.status == PROTOCOL_BINARY_RESPONSE_SUCCESS) {
14081413 const auto & mloc = op.result .matchloc ();
1409- *reinterpret_cast <uint32_t *>(cursor) = htonl (mloc.length );
1414+ *reinterpret_cast <uint32_t *>(cursor) =
1415+ htonl (gsl::narrow<uint32_t >(mloc.length ));
14101416 cursor += sizeof (uint32_t );
14111417 }
14121418 return cursor - buffer;
@@ -1534,20 +1540,21 @@ static void subdoc_multi_mutation_response(Cookie& cookie,
15341540 }
15351541
15361542 // Allocated required resource - build the header.
1537- mcbp_add_header (cookie,
1538- status_code,
1539- extlen,
1540- /* keylen*/ 0 ,
1541- extlen + response_buf_needed + iov_len,
1542- PROTOCOL_BINARY_RAW_BYTES);
1543+ mcbp_add_header (
1544+ cookie,
1545+ status_code,
1546+ gsl::narrow<uint8_t >(extlen),
1547+ /* keylen*/ 0 ,
1548+ gsl::narrow<uint32_t >(extlen + response_buf_needed + iov_len),
1549+ PROTOCOL_BINARY_RAW_BYTES);
15431550
15441551 // Append extras if requested.
15451552 if (extlen > 0 ) {
15461553 connection.addIov (reinterpret_cast <void *>(extras_ptr), extlen);
15471554 }
15481555
15491556 // Append the iovecs for each operation result.
1550- size_t index = 0 ;
1557+ uint8_t index = 0 ;
15511558 for (auto phase : phases) {
15521559 for (size_t ii = 0 ; ii < context.getOperations (phase).size (); ii++, index++) {
15531560 const auto & op = context.getOperations (phase)[ii];
@@ -1557,7 +1564,7 @@ static void subdoc_multi_mutation_response(Cookie& cookie,
15571564 if (op.traits .responseHasValue () && mloc.length > 0 ) {
15581565 char * header = response_buf.getCurrent ();
15591566 size_t header_sz =
1560- encode_multi_mutation_result_spec (index, op, header);
1567+ encode_multi_mutation_result_spec (index, op, header);
15611568
15621569 connection.addIov (reinterpret_cast <void *>(header),
15631570 header_sz);
@@ -1570,7 +1577,7 @@ static void subdoc_multi_mutation_response(Cookie& cookie,
15701577 if (op.status != PROTOCOL_BINARY_RESPONSE_SUCCESS) {
15711578 char * header = response_buf.getCurrent ();
15721579 size_t header_sz =
1573- encode_multi_mutation_result_spec (index, op, header);
1580+ encode_multi_mutation_result_spec (index, op, header);
15741581
15751582 connection.addIov (reinterpret_cast <void *>(header),
15761583 header_sz);
@@ -1641,7 +1648,7 @@ static void subdoc_multi_lookup_response(Cookie& cookie,
16411648 status_code,
16421649 /* extlen*/ 0 , /* keylen*/
16431650 0 ,
1644- context.response_val_len ,
1651+ gsl::narrow< uint32_t >( context.response_val_len ) ,
16451652 PROTOCOL_BINARY_RAW_BYTES);
16461653
16471654 // Append the iovecs for each operation result.
0 commit comments