Skip to content

Commit

Permalink
Fix format warnings (#4601)
Browse files Browse the repository at this point in the history
  • Loading branch information
twose authored Feb 9, 2022
1 parent b95765b commit 5b12a03
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions ext-src/swoole_coroutine_system.cc
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ PHP_METHOD(swoole_coroutine_system, fread) {
}
buf[length] = 0;
int ret = -1;
swoole_trace("fd=%d, length=%ld", fd, length);
swoole_trace("fd=%d, length=" ZEND_LONG_FMT, fd, length);
php_swoole_check_reactor();
bool async_success = swoole::coroutine::async([&]() {
while (1) {
Expand Down Expand Up @@ -277,7 +277,7 @@ PHP_METHOD(swoole_coroutine_system, fwrite) {
}

int ret = -1;
swoole_trace("fd=%d, length=%ld", fd, length);
swoole_trace("fd=%d, length=" ZEND_LONG_FMT, fd, length);
php_swoole_check_reactor();
bool async_success = swoole::coroutine::async([&]() {
while (1) {
Expand Down
2 changes: 1 addition & 1 deletion ext-src/swoole_http2_client_coro.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ bool Client::send_goaway_frame(zend_long error_code, const char *debug_data, siz
memcpy(frame + SW_HTTP2_FRAME_HEADER_SIZE + SW_HTTP2_GOAWAY_SIZE, debug_data, debug_data_len);
}
swoole_trace_log(SW_TRACE_HTTP2,
"[" SW_ECHO_GREEN "] Send: last-sid=%u, error-code=%ld",
"[" SW_ECHO_GREEN "] Send: last-sid=%u, error-code=" ZEND_LONG_FMT,
Http2::get_type(SW_HTTP2_TYPE_GOAWAY),
last_stream_id,
error_code);
Expand Down
4 changes: 2 additions & 2 deletions ext-src/swoole_http_server_coro.cc
Original file line number Diff line number Diff line change
Expand Up @@ -578,10 +578,10 @@ static PHP_METHOD(swoole_http_server_coro, onAccept) {
buffer->offset += parsed_n;

swoole_trace_log(SW_TRACE_CO_HTTP_SERVER,
"parsed_n=%ld, length=%ld, offset=%ld, completed=%d",
"parsed_n=%zu, length=%zu, offset=%jd, completed=%u",
parsed_n,
buffer->length,
buffer->offset,
(intmax_t) buffer->offset,
ctx->completed);

if (!ctx->completed) {
Expand Down
4 changes: 2 additions & 2 deletions ext-src/swoole_mysql_coro.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1497,11 +1497,11 @@ void mysql_statement::fetch(zval *return_value) {
if (field->flags & SW_MYSQL_UNSIGNED_FLAG) {
add_assoc_ulong_safe_ex(return_value, field->name, field->name_length, *(uint64_t *) p);
swoole_trace_log(
SW_TRACE_MYSQL_CLIENT, "%.*s=%lu", field->name_length, field->name, *(uint64_t *) p);
SW_TRACE_MYSQL_CLIENT, "%.*s=%" PRIu64, field->name_length, field->name, *(uint64_t *) p);
} else {
add_assoc_long_ex(return_value, field->name, field->name_length, *(int64_t *) p);
swoole_trace_log(
SW_TRACE_MYSQL_CLIENT, "%.*s=%ld", field->name_length, field->name, *(int64_t *) p);
SW_TRACE_MYSQL_CLIENT, "%.*s=%" PRId64, field->name_length, field->name, *(int64_t *) p);
}
break;
case SW_MYSQL_TYPE_FLOAT: {
Expand Down
2 changes: 1 addition & 1 deletion ext-src/swoole_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3592,7 +3592,7 @@ static PHP_METHOD(swoole_server, getClientList) {
int fd = start_fd + 1;

for (; fd <= serv_max_fd; fd++) {
swoole_trace("maxfd=%d, fd=%d, find_count=%ld, start_fd=%ld", serv_max_fd, fd, find_count, start_session_id);
swoole_trace("maxfd=%d, fd=%d, find_count=" ZEND_LONG_FMT ", start_fd=" ZEND_LONG_FMT, serv_max_fd, fd, find_count, start_session_id);
Connection *conn = serv->get_connection_for_iterator(fd);
if (conn) {
SessionId session_id = conn->session_id;
Expand Down
2 changes: 1 addition & 1 deletion ext-src/swoole_websocket_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ static PHP_METHOD(swoole_websocket_server, push) {
Connection *conn = serv->get_connection_verify(fd);
if (!conn) {
swoole_set_last_error(SW_ERROR_SESSION_NOT_EXIST);
php_swoole_fatal_error(E_WARNING, "session#%ld does not exists", fd);
php_swoole_fatal_error(E_WARNING, "session#" ZEND_LONG_FMT " does not exists", fd);
RETURN_FALSE;
}
allow_compress = conn->websocket_compression;
Expand Down
2 changes: 1 addition & 1 deletion include/swoole_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ swoole::Logger *sw_logger();
hof += sprintf(hex + hof, "%02x ", (__data)[i] & 0xff); \
sof += sprintf(str + sof, "%c", isprint((int) (__data)[i]) ? (__data)[i] : '.'); \
} \
swoole_debug("| %08x | %-48s| %-16s |", of, hex, str); \
swoole_debug("| %08zx | %-48s| %-16s |", of, hex, str); \
} \
swoole_debug("+----------+------------+-----------+-----------+------------+------------------+"); \
} while (0)
Expand Down
2 changes: 1 addition & 1 deletion src/core/base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ size_t DataHead::dump(char *_buf, size_t _len) {
"DataHead[%p]\n"
"{\n"
" long fd = %ld;\n"
" uint64_t msg_id = %lu;\n"
" uint64_t msg_id = %" PRIu64 ";\n"
" uint32_t len = %d;\n"
" int16_t reactor_id = %d;\n"
" uint8_t type = %d;\n"
Expand Down
8 changes: 4 additions & 4 deletions src/core/string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,11 @@ ssize_t String::split(const char *delimiter, size_t delimiter_length, const Stri
off_t _offset = offset;
size_t ret;

swoole_trace_log(SW_TRACE_EOF_PROTOCOL, "#[0] count=%d, length=%ld, size=%ld, offset=%ld", count, length, size, offset);
swoole_trace_log(SW_TRACE_EOF_PROTOCOL, "#[0] count=%d, length=%ld, size=%ld, offset=%jd", count, length, size, (intmax_t) offset);

while (delimiter_addr) {
size_t _length = delimiter_addr - start_addr + delimiter_length;
swoole_trace_log(SW_TRACE_EOF_PROTOCOL, "#[4] count=%d, length=%lu", count, _length + offset);
swoole_trace_log(SW_TRACE_EOF_PROTOCOL, "#[4] count=%d, length=%zu", count, (size_t) (_length + offset));
if (handler((char *) start_addr - _offset, _length + _offset) == false) {
return -1;
}
Expand All @@ -207,9 +207,9 @@ ssize_t String::split(const char *delimiter, size_t delimiter_length, const Stri

ret = start_addr - str - _offset;
if (ret > 0 && ret < length) {
swoole_trace_log(SW_TRACE_EOF_PROTOCOL, "#[5] count=%d, remaining_length=%zu", count, length - offset);
swoole_trace_log(SW_TRACE_EOF_PROTOCOL, "#[5] count=%d, remaining_length=%zu", count, (size_t) (length - offset));
} else if (ret >= length) {
swoole_trace_log(SW_TRACE_EOF_PROTOCOL, "#[3] length=%ld, size=%ld, offset=%ld", length, size, offset);
swoole_trace_log(SW_TRACE_EOF_PROTOCOL, "#[3] length=%ld, size=%zu, offset=%jd", length, size, (intmax_t) offset);
}

return ret;
Expand Down
2 changes: 1 addition & 1 deletion src/os/sendfile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int swoole_sendfile(int out_fd, int in_fd, off_t *offset, size_t size) {

// sent_bytes = (off_t)size;
swoole_trace(
"send file, ret:%d, out_fd:%d, in_fd:%d, offset:%jd, size:%zu", ret, out_fd, in_fd, (intmax_t) *offset, size);
"send file, ret: %zd, out_fd:%d, in_fd:%d, offset:%jd, size:%zu", ret, out_fd, in_fd, (intmax_t) *offset, size);

#ifdef __MACH__
*offset += size;
Expand Down
4 changes: 2 additions & 2 deletions src/protocol/dtls.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ long BIO_ctrl(BIO *b, int cmd, long lval, void *ptrval) {
long retval = 0;
Session *session = (Session *) BIO_get_data(b);

swoole_trace_log(SW_TRACE_SSL, "BIO_ctrl(BIO[0x%016lX], cmd[%d], lval[%ld], ptrval[0x%016lX])", b, cmd, lval, ptrval);
swoole_trace_log(SW_TRACE_SSL, "BIO_ctrl(BIO[%p], cmd[%d], lval[%ld], ptrval[%p])", b, cmd, lval, ptrval);

switch (cmd) {
case BIO_CTRL_EOF:
Expand Down Expand Up @@ -101,7 +101,7 @@ int BIO_create(BIO *b) {
}

int BIO_destroy(BIO *b) {
swoole_trace_log(SW_TRACE_SSL, "BIO_destroy(BIO[0x%016lX])\n", b);
swoole_trace_log(SW_TRACE_SSL, "BIO_destroy(BIO[%p])\n", b);
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/protocol/websocket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static ssize_t get_package_length_impl(PacketLength *pl) {
if ((ssize_t) payload_length < 0) {
return -1;
}
swoole_trace_log(SW_TRACE_LENGTH_PROTOCOL, "header_length=%u, payload_length=%lu", pl->header_len, payload_length);
swoole_trace_log(SW_TRACE_LENGTH_PROTOCOL, "header_length=%u, payload_length=%" PRIu64, pl->header_len, payload_length);

return (ssize_t) pl->header_len + (ssize_t) payload_length;
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/master.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void Server::call_command_callback(int64_t request_id, const std::string &result
auto iter = command_callbacks.find(request_id);
if (iter == command_callbacks.end()) {
swoole_error_log(
SW_LOG_ERROR, SW_ERROR_SERVER_INVALID_COMMAND, "Invalid command result[request_id=%ld]", request_id);
SW_LOG_ERROR, SW_ERROR_SERVER_INVALID_COMMAND, "Invalid command result[request_id=%" PRId64 "]", request_id);
return;
}
iter->second(this, result);
Expand Down
8 changes: 4 additions & 4 deletions src/server/message_bus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ ReturnCode MessageBus::prepare_packet(uint16_t &recv_chunk_count, String *packet
*/
buffer_->info.flags |= SW_EVENT_DATA_OBJ_PTR;
memcpy(buffer_->data, &packet_buffer, sizeof(packet_buffer));
swoole_trace("msg_id=%ld, len=%u", buffer_->info.msg_id, buffer_->info.len);
swoole_trace("msg_id=%" PRIu64 ", len=%u", buffer_->info.msg_id, buffer_->info.len);

return SW_READY;
}
Expand Down Expand Up @@ -99,7 +99,7 @@ ssize_t MessageBus::read(Socket *sock) {
if (packet_buffer == nullptr) {
swoole_error_log(SW_LOG_WARNING,
SW_ERROR_SERVER_WORKER_ABNORMAL_PIPE_DATA,
"abnormal pipeline data, msg_id=%ld, pipe_fd=%d, reactor_id=%d",
"abnormal pipeline data, msg_id=%" PRIu64 ", pipe_fd=%d, reactor_id=%d",
info->msg_id,
sock->get_fd(),
info->reactor_id);
Expand All @@ -122,7 +122,7 @@ ssize_t MessageBus::read(Socket *sock) {
}
if (recv_n > 0) {
packet_buffer->length += (recv_n - sizeof(buffer_->info));
swoole_trace("append msgid=%ld, buffer=%p, n=%ld", buffer_->info.msg_id, packet_buffer, recv_n);
swoole_trace("append msgid=%" PRIu64 ", buffer=%p, n=%ld", buffer_->info.msg_id, packet_buffer, recv_n);
}

switch (prepare_packet(recv_chunk_count, packet_buffer)) {
Expand Down Expand Up @@ -167,7 +167,7 @@ ssize_t MessageBus::read_with_buffer(network::Socket *sock) {
if (packet_buffer == nullptr) {
swoole_error_log(SW_LOG_WARNING,
SW_ERROR_SERVER_WORKER_ABNORMAL_PIPE_DATA,
"abnormal pipeline data, msg_id=%ld, pipe_fd=%d, reactor_id=%d",
"abnormal pipeline data, msg_id=%" PRIu64 ", pipe_fd=%d, reactor_id=%d",
buffer_->info.msg_id,
sock->get_fd(),
buffer_->info.reactor_id);
Expand Down
6 changes: 3 additions & 3 deletions src/server/port.cc
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ static int Port_onRead_http(Reactor *reactor, ListenPort *port, Event *event) {
if (!request->header_parsed) {
request->parse_header_info();
swoole_trace_log(SW_TRACE_SERVER,
"content-length=%u, keep-alive=%u, chunked=%u",
"content-length=%" PRIu64 ", keep-alive=%u, chunked=%u",
request->content_length_,
request->keep_alive,
request->chunked);
Expand Down Expand Up @@ -591,13 +591,13 @@ static int Port_onRead_http(Reactor *reactor, ListenPort *port, Event *event) {
} else {
request_length = request->header_length_ + request->content_length_;
}
swoole_trace_log(SW_TRACE_SERVER, "received chunked eof, real content-length=%u", request->content_length_);
swoole_trace_log(SW_TRACE_SERVER, "received chunked eof, real content-length=%" PRIu64, request->content_length_);
} else {
request_length = request->header_length_ + request->content_length_;
if (request_length > protocol->package_max_length) {
swoole_error_log(SW_LOG_WARNING,
SW_ERROR_HTTP_INVALID_PROTOCOL,
"Request Entity Too Large: header-length (%u) + content-length (%lu) is greater than the "
"Request Entity Too Large: header-length (%u) + content-length (%" PRIu64 ") is greater than the "
"package_max_length(%u)" CLIENT_INFO_FMT,
request->header_length_,
request->content_length_,
Expand Down

0 comments on commit 5b12a03

Please sign in to comment.