Remove MYSQLND_SZ_T_SPEC

In favor of %zu, which msvc has supported for quite a while already.
This commit is contained in:
Nikita Popov 2021-08-12 15:29:06 +02:00
parent 8f5555605a
commit b80767e219
5 changed files with 26 additions and 28 deletions

View File

@ -47,13 +47,11 @@ This file is public domain and comes with NO WARRANTY of any kind */
/* Go around some bugs in different OS and compilers */
#ifdef PHP_WIN32
#define MYSQLND_SZ_T_SPEC "%Id"
#ifndef L64
#define L64(x) x##i64
#endif
#else
#define MYSQLND_SZ_T_SPEC "%zd"
#ifndef L64
#define L64(x) x##LL
#endif

View File

@ -70,7 +70,7 @@ static ssize_t write_compressed_packet(
int3store(compress_buf, payload_size);
int1store(compress_buf + 3, pfc->data->compressed_envelope_packet_no);
DBG_INF_FMT("writing "MYSQLND_SZ_T_SPEC" bytes to the network", payload_size + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE);
DBG_INF_FMT("writing %zu bytes to the network", payload_size + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE);
ssize_t bytes_sent = vio->data->m.network_write(vio, compress_buf, payload_size + MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE, conn_stats, error_info);
pfc->data->compressed_envelope_packet_no++;
@ -125,11 +125,11 @@ MYSQLND_METHOD(mysqlnd_pfc, send)(MYSQLND_PFC * const pfc, MYSQLND_VIO * const v
ssize_t bytes_sent;
DBG_ENTER("mysqlnd_pfc::send");
DBG_INF_FMT("count=" MYSQLND_SZ_T_SPEC " compression=%u", count, pfc->data->compressed);
DBG_INF_FMT("count=%zu compression=%u", count, pfc->data->compressed);
if (pfc->data->compressed == TRUE) {
size_t comp_buf_size = MYSQLND_HEADER_SIZE + COMPRESSED_HEADER_SIZE + MYSQLND_HEADER_SIZE + MIN(left, MYSQLND_MAX_PACKET_SIZE);
DBG_INF_FMT("compress_buf_size="MYSQLND_SZ_T_SPEC, comp_buf_size);
DBG_INF_FMT("compress_buf_size=%zu", comp_buf_size);
compress_buf = mnd_emalloc(comp_buf_size);
}
@ -187,7 +187,7 @@ MYSQLND_METHOD(mysqlnd_pfc, send)(MYSQLND_PFC * const pfc, MYSQLND_VIO * const v
*/
} while (bytes_sent > 0 && (left > 0 || to_be_sent == MYSQLND_MAX_PACKET_SIZE));
DBG_INF_FMT("packet_size="MYSQLND_SZ_T_SPEC" packet_no=%u", left, pfc->data->packet_no);
DBG_INF_FMT("packet_size=%zu packet_no=%u", left, pfc->data->packet_no);
MYSQLND_INC_CONN_STATISTIC_W_VALUE3(conn_stats,
STAT_BYTES_SENT, count + packets_sent * MYSQLND_HEADER_SIZE,
@ -270,7 +270,7 @@ MYSQLND_METHOD(mysqlnd_pfc, decode)(zend_uchar * uncompressed_data, const size_t
DBG_ENTER("mysqlnd_pfc::decode");
error = uncompress(uncompressed_data, &tmp_complen, compressed_data, compressed_data_len);
DBG_INF_FMT("compressed data: decomp_len=%lu compressed_size="MYSQLND_SZ_T_SPEC, tmp_complen, compressed_data_len);
DBG_INF_FMT("compressed data: decomp_len=%lu compressed_size=%zu", tmp_complen, compressed_data_len);
if (error != Z_OK) {
DBG_INF_FMT("decompression NOT successful. error=%d Z_OK=%d Z_BUF_ERROR=%d Z_MEM_ERROR=%d", error, Z_OK, Z_BUF_ERROR, Z_MEM_ERROR);
}
@ -323,13 +323,13 @@ MYSQLND_METHOD(mysqlnd_pfc, receive)(MYSQLND_PFC * const pfc, MYSQLND_VIO * cons
if (pfc->data->compressed) {
if (pfc->data->uncompressed_data) {
size_t to_read_from_buffer = MIN(pfc->data->uncompressed_data->bytes_left(pfc->data->uncompressed_data), to_read);
DBG_INF_FMT("reading "MYSQLND_SZ_T_SPEC" from uncompressed_data buffer", to_read_from_buffer);
DBG_INF_FMT("reading %zu from uncompressed_data buffer", to_read_from_buffer);
if (to_read_from_buffer) {
pfc->data->uncompressed_data->read(pfc->data->uncompressed_data, to_read_from_buffer, (zend_uchar *) p);
p += to_read_from_buffer;
to_read -= to_read_from_buffer;
}
DBG_INF_FMT("left "MYSQLND_SZ_T_SPEC" to read", to_read);
DBG_INF_FMT("left %zu to read", to_read);
if (TRUE == pfc->data->uncompressed_data->is_empty(pfc->data->uncompressed_data)) {
/* Everything was consumed. This should never happen here, but for security */
pfc->data->uncompressed_data->free_buffer(&pfc->data->uncompressed_data);
@ -346,10 +346,10 @@ MYSQLND_METHOD(mysqlnd_pfc, receive)(MYSQLND_PFC * const pfc, MYSQLND_VIO * cons
net_payload_size = uint3korr(net_header);
packet_no = uint1korr(net_header + 3);
if (pfc->data->compressed_envelope_packet_no != packet_no) {
DBG_ERR_FMT("Transport level: packets out of order. Expected %u received %u. Packet size="MYSQLND_SZ_T_SPEC,
DBG_ERR_FMT("Transport level: packets out of order. Expected %u received %u. Packet size=%zu",
pfc->data->compressed_envelope_packet_no, packet_no, net_payload_size);
php_error(E_WARNING, "Packets out of order. Expected %u received %u. Packet size="MYSQLND_SZ_T_SPEC,
php_error(E_WARNING, "Packets out of order. Expected %u received %u. Packet size=%zu",
pfc->data->compressed_envelope_packet_no, packet_no, net_payload_size);
DBG_RETURN(FAIL);
}
@ -400,7 +400,7 @@ MYSQLND_METHOD(mysqlnd_pfc, set_client_option)(MYSQLND_PFC * const pfc, enum_mys
DBG_RETURN(FAIL);
}
pfc->cmd_buffer.length = *(unsigned int*) value;
DBG_INF_FMT("new_length="MYSQLND_SZ_T_SPEC, pfc->cmd_buffer.length);
DBG_INF_FMT("new_length=%zu", pfc->cmd_buffer.length);
if (!pfc->cmd_buffer.buffer) {
pfc->cmd_buffer.buffer = mnd_pemalloc(pfc->cmd_buffer.length, pfc->persistent);
} else {

View File

@ -1096,7 +1096,7 @@ MYSQLND_METHOD(mysqlnd_stmt, send_long_data)(MYSQLND_STMT * const s, unsigned in
php_error_docref(NULL, E_WARNING, "There was an error "
"while sending long data. Probably max_allowed_packet_size "
"is smaller than the data. You have to increase it or send "
"smaller chunks of data. Answer was "MYSQLND_SZ_T_SPEC" bytes long.", packet_len);
"smaller chunks of data. Answer was %zu bytes long.", packet_len);
SET_CLIENT_ERROR(stmt->error_info, CR_CONNECTION_ERROR, UNKNOWN_SQLSTATE,
"Server responded to COM_STMT_SEND_LONG_DATA.");
ret = FAIL;

View File

@ -81,7 +81,7 @@ MYSQLND_METHOD(mysqlnd_vio, network_read)(MYSQLND_VIO * const vio, zend_uchar *
zend_uchar * p = buffer;
DBG_ENTER("mysqlnd_vio::network_read");
DBG_INF_FMT("count="MYSQLND_SZ_T_SPEC, count);
DBG_INF_FMT("count=%zu", count);
while (to_read) {
ssize_t ret = php_stream_read(net_stream, (char *) p, to_read);
@ -331,7 +331,7 @@ MYSQLND_METHOD(mysqlnd_vio, set_client_option)(MYSQLND_VIO * const net, enum_mys
case MYSQLND_OPT_NET_READ_BUFFER_SIZE:
DBG_INF("MYSQLND_OPT_NET_READ_BUFFER_SIZE");
net->data->options.net_read_buffer_size = *(unsigned int*) value;
DBG_INF_FMT("new_length="MYSQLND_SZ_T_SPEC, net->data->options.net_read_buffer_size);
DBG_INF_FMT("new_length=%zu", net->data->options.net_read_buffer_size);
break;
case MYSQL_OPT_CONNECT_TIMEOUT:
DBG_INF("MYSQL_OPT_CONNECT_TIMEOUT");

View File

@ -266,10 +266,10 @@ mysqlnd_read_header(MYSQLND_PFC * pfc, MYSQLND_VIO * vio, MYSQLND_PACKET_HEADER
DBG_RETURN(PASS);
}
DBG_ERR_FMT("Logical link: packets out of order. Expected %u received %u. Packet size="MYSQLND_SZ_T_SPEC,
DBG_ERR_FMT("Logical link: packets out of order. Expected %u received %u. Packet size=%zu",
pfc->data->packet_no, header->packet_no, header->size);
php_error(E_WARNING, "Packets out of order. Expected %u received %u. Packet size="MYSQLND_SZ_T_SPEC,
php_error(E_WARNING, "Packets out of order. Expected %u received %u. Packet size=%zu",
pfc->data->packet_no, header->packet_no, header->size);
DBG_RETURN(FAIL);
}
@ -452,7 +452,7 @@ php_mysqlnd_greet_read(MYSQLND_CONN_DATA * conn, void * _packet)
DBG_RETURN(PASS);
premature_end:
DBG_ERR_FMT("GREET packet %zu bytes shorter than expected", p - begin - packet->header.size);
php_error_docref(NULL, E_WARNING, "GREET packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected",
php_error_docref(NULL, E_WARNING, "GREET packet %zu bytes shorter than expected",
p - begin - packet->header.size);
DBG_RETURN(FAIL);
}
@ -727,7 +727,7 @@ php_mysqlnd_auth_response_read(MYSQLND_CONN_DATA * conn, void * _packet)
DBG_RETURN(PASS);
premature_end:
DBG_ERR_FMT("OK packet %zu bytes shorter than expected", p - begin - packet->header.size);
php_error_docref(NULL, E_WARNING, "AUTH_RESPONSE packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected",
php_error_docref(NULL, E_WARNING, "AUTH_RESPONSE packet %zu bytes shorter than expected",
p - begin - packet->header.size);
DBG_RETURN(FAIL);
}
@ -867,7 +867,7 @@ php_mysqlnd_ok_read(MYSQLND_CONN_DATA * conn, void * _packet)
DBG_RETURN(PASS);
premature_end:
DBG_ERR_FMT("OK packet %zu bytes shorter than expected", p - begin - packet->header.size);
php_error_docref(NULL, E_WARNING, "OK packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected",
php_error_docref(NULL, E_WARNING, "OK packet %zu bytes shorter than expected",
p - begin - packet->header.size);
DBG_RETURN(FAIL);
}
@ -954,7 +954,7 @@ php_mysqlnd_eof_read(MYSQLND_CONN_DATA * conn, void * _packet)
DBG_RETURN(PASS);
premature_end:
DBG_ERR_FMT("EOF packet %zu bytes shorter than expected", p - begin - packet->header.size);
php_error_docref(NULL, E_WARNING, "EOF packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected",
php_error_docref(NULL, E_WARNING, "EOF packet %zu bytes shorter than expected",
p - begin - packet->header.size);
DBG_RETURN(FAIL);
}
@ -1114,7 +1114,7 @@ php_mysqlnd_rset_header_read(MYSQLND_CONN_DATA * conn, void * _packet)
DBG_RETURN(ret);
premature_end:
DBG_ERR_FMT("RSET_HEADER packet %zu bytes shorter than expected", p - begin - packet->header.size);
php_error_docref(NULL, E_WARNING, "RSET_HEADER packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected",
php_error_docref(NULL, E_WARNING, "RSET_HEADER packet %zu bytes shorter than expected",
p - begin - packet->header.size);
DBG_RETURN(FAIL);
}
@ -1327,7 +1327,7 @@ faulty_or_fake:
DBG_RETURN(FAIL);
premature_end:
DBG_ERR_FMT("RSET field packet %zu bytes shorter than expected", p - begin - packet->header.size);
php_error_docref(NULL, E_WARNING, "Result set field packet "MYSQLND_SZ_T_SPEC" bytes "
php_error_docref(NULL, E_WARNING, "Result set field packet %zu bytes "
"shorter than expected", p - begin - packet->header.size);
DBG_RETURN(FAIL);
}
@ -1540,7 +1540,7 @@ php_mysqlnd_rowp_read_text_protocol(MYSQLND_ROW_BUFFER * row_buffer, zval * fiel
if (len == MYSQLND_NULL_LENGTH) {
ZVAL_NULL(current_field);
} else if ((p + len) > packet_end) {
php_error_docref(NULL, E_WARNING, "Malformed server packet. Field length pointing "MYSQLND_SZ_T_SPEC
php_error_docref(NULL, E_WARNING, "Malformed server packet. Field length pointing %zu"
" bytes after end of packet", (p + len) - packet_end - 1);
DBG_RETURN(FAIL);
} else {
@ -1852,7 +1852,7 @@ php_mysqlnd_prepare_read(MYSQLND_CONN_DATA * conn, void * _packet)
DBG_RETURN(PASS);
premature_end:
DBG_ERR_FMT("PREPARE packet %zu bytes shorter than expected", p - begin - packet->header.size);
php_error_docref(NULL, E_WARNING, "PREPARE packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected",
php_error_docref(NULL, E_WARNING, "PREPARE packet %zu bytes shorter than expected",
p - begin - packet->header.size);
DBG_RETURN(FAIL);
}
@ -1922,7 +1922,7 @@ php_mysqlnd_chg_user_read(MYSQLND_CONN_DATA * conn, void * _packet)
DBG_RETURN(PASS);
premature_end:
DBG_ERR_FMT("CHANGE_USER packet %zu bytes shorter than expected", p - begin - packet->header.size);
php_error_docref(NULL, E_WARNING, "CHANGE_USER packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected",
php_error_docref(NULL, E_WARNING, "CHANGE_USER packet %zu bytes shorter than expected",
p - begin - packet->header.size);
DBG_RETURN(FAIL);
}
@ -2007,7 +2007,7 @@ php_mysqlnd_sha256_pk_request_response_read(MYSQLND_CONN_DATA * conn, void * _pa
premature_end:
DBG_ERR_FMT("OK packet %zu bytes shorter than expected", p - begin - packet->header.size);
php_error_docref(NULL, E_WARNING, "SHA256_PK_REQUEST_RESPONSE packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected",
php_error_docref(NULL, E_WARNING, "SHA256_PK_REQUEST_RESPONSE packet %zu bytes shorter than expected",
p - begin - packet->header.size);
DBG_RETURN(FAIL);
}
@ -2119,7 +2119,7 @@ php_mysqlnd_cached_sha2_result_read(MYSQLND_CONN_DATA * conn, void * _packet)
premature_end:
DBG_ERR_FMT("OK packet %zu bytes shorter than expected", p - begin - packet->header.size);
php_error_docref(NULL, E_WARNING, "SHA256_PK_REQUEST_RESPONSE packet "MYSQLND_SZ_T_SPEC" bytes shorter than expected",
php_error_docref(NULL, E_WARNING, "SHA256_PK_REQUEST_RESPONSE packet %zu bytes shorter than expected",
p - begin - packet->header.size);
DBG_RETURN(FAIL);
}