Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
fetch-depth: 0
- name: install clang-format
run: sudo apt install clang-format
run: pip install clang-format
- name: check-diff
run: |
diff=`git-clang-format --diff HEAD^`
Expand Down
2 changes: 1 addition & 1 deletion include/ylt/coro_io/io_context_pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ class multithread_context_pool {
~multithread_context_pool() { stop(); }

void run() {
for (int i = 0; i < thd_num_; i++) {
for (size_t i = 0; i < thd_num_; i++) {
thds_.emplace_back([this] {
ioc_.run();
});
Expand Down
22 changes: 10 additions & 12 deletions include/ylt/coro_rpc/impl/coro_rpc_client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ struct async_rpc_result_value_t : public detail::async_rpc_result_base {
T result_;

public:
async_rpc_result_value_t(T &&result, resp_body &&buffer,
async_rpc_result_value_t(T&& result, resp_body&& buffer,
coro_io::data_view attachment)
: result_(std::move(result)),
async_rpc_result_base(std::move(buffer), attachment) {}
: async_rpc_result_base(std::move(buffer), attachment),
result_(std::move(result)) {}
async_rpc_result_value_t(T &&result) : result_(std::move(result)) {}
T &result() noexcept { return result_; }
const T &result() const noexcept { return result_; }
Expand Down Expand Up @@ -268,11 +268,11 @@ class coro_rpc_client {
* @param executor coro_io's executor, default executor is come
*/
coro_rpc_client(
coro_io::ExecutorWrapper<> *executor = coro_io::get_global_executor(),
coro_io::ExecutorWrapper<>* executor = coro_io::get_global_executor(),
config conf = {})
: control_(std::make_shared<control_t>(executor, false, conf.local_ip)),
timer_(std::make_unique<coro_io::period_timer>(
executor->get_asio_executor())) {
: timer_(std::make_unique<coro_io::period_timer>(
executor->get_asio_executor())),
control_(std::make_shared<control_t>(executor, false, conf.local_ip)) {
if (!init_config(conf)) [[unlikely]] {
close();
}
Expand Down Expand Up @@ -1388,10 +1388,8 @@ class coro_rpc_client {
private:
template <auto func, typename Socket, typename... Args>
async_simple::coro::Lazy<rpc_error> send_request_for_impl(
Socket &soc, request_config_t &config, uint32_t &id,
coro_io::period_timer &timer, Args &&...args) {
using R = decltype(get_return_type<func>());

Socket& soc, request_config_t& config, uint32_t& id,
coro_io::period_timer& timer, Args&&... args) {
if (control_->has_closed_)
AS_UNLIKELY {
ELOG_ERROR << "client has been closed, please re-connect"
Expand Down Expand Up @@ -1438,7 +1436,7 @@ class coro_rpc_client {
char buffer[coro_rpc_protocol::RESP_HEAD_LEN];
auto tp = std::chrono::steady_clock::now();
ret = co_await coro_io::async_read(socket, asio::buffer(buffer));
auto ec = struct_pack::deserialize_to<
[[maybe_unused]] auto ec = struct_pack::deserialize_to<
struct_pack::sp_config::DISABLE_ALL_META_INFO>(
header, std::string_view{buffer, buffer + sizeof(buffer)});
assert(!ec);
Expand Down
14 changes: 7 additions & 7 deletions include/ylt/coro_rpc/impl/coro_rpc_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ class coro_rpc_server_base {
conn_timeout_duration = std::chrono::seconds(0),
bool is_enable_tcp_no_delay = true)
: pool_(thread_num),
conn_timeout_duration_(conn_timeout_duration),
flag_{stat::init},
is_enable_tcp_no_delay_(is_enable_tcp_no_delay) {
is_enable_tcp_no_delay_(is_enable_tcp_no_delay),
conn_timeout_duration_(conn_timeout_duration) {
acceptors_.push_back(
std::make_unique<coro_io::tcp_server_acceptor>(address, port));
}
Expand All @@ -99,21 +99,21 @@ class coro_rpc_server_base {
conn_timeout_duration = std::chrono::seconds(0),
bool is_enable_tcp_no_delay = true)
: pool_(thread_num),
conn_timeout_duration_(conn_timeout_duration),
flag_{stat::init},
is_enable_tcp_no_delay_(is_enable_tcp_no_delay) {
is_enable_tcp_no_delay_(is_enable_tcp_no_delay),
conn_timeout_duration_(conn_timeout_duration) {
acceptors_.push_back(
std::make_unique<coro_io::tcp_server_acceptor>(address));
}

coro_rpc_server_base(
const server_config &config,
const server_config& config,
std::vector<std::unique_ptr<coro_io::server_acceptor_base>> acceptors =
{})
: pool_(config.thread_num),
conn_timeout_duration_(config.conn_timeout_duration),
flag_{stat::init},
is_enable_tcp_no_delay_(config.is_enable_tcp_no_delay) {
is_enable_tcp_no_delay_(config.is_enable_tcp_no_delay),
conn_timeout_duration_(config.conn_timeout_duration) {
#ifdef YLT_ENABLE_SSL
if (config.ssl_config) {
use_ssl_ = init_ssl_context_helper(context_, config.ssl_config.value());
Expand Down
4 changes: 0 additions & 4 deletions include/ylt/coro_rpc/impl/protocol/coro_rpc_protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ struct coro_rpc_protocol {
if (ec) [[unlikely]] {
co_return std::move(ec);
}
auto i = struct_pack::get_needed_size<
struct_pack::sp_config::DISABLE_ALL_META_INFO>(req_head);
auto ec2 = struct_pack::deserialize_to<
struct_pack::sp_config::DISABLE_ALL_META_INFO>(
req_head,
Expand Down Expand Up @@ -179,8 +177,6 @@ struct coro_rpc_protocol {
if (ec) [[unlikely]] {
co_return std::move(ec);
}
auto i = struct_pack::get_needed_size<
struct_pack::sp_config::DISABLE_ALL_META_INFO>(req_head);
auto ec2 = struct_pack::deserialize_to<
struct_pack::sp_config::DISABLE_ALL_META_INFO>(
req_head,
Expand Down
6 changes: 3 additions & 3 deletions include/ylt/easylog/appender.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ constexpr char digits[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};

template <size_t N, char c>
inline void to_int(int num, char *p, int &size) {
for (int i = 0; i < N; i++) {
for (size_t i = 0; i < N; i++) {
p[--size] = digits[num % 10];
num = num / 10;
}
Expand Down Expand Up @@ -94,11 +94,11 @@ inline char *get_time_str(const auto &now) {
class appender {
public:
appender() = default;
appender(const std::string &filename, bool async, bool enable_console,
appender(const std::string& filename, bool async, bool enable_console,
size_t max_file_size, size_t max_files, bool flush_every_time)
: has_init_(true),
flush_every_time_(flush_every_time),
enable_console_(enable_console),
flush_every_time_(flush_every_time),
max_file_size_(max_file_size) {
filename_ = filename;
max_files_ = (std::min)(max_files, static_cast<size_t>(1000));
Expand Down
4 changes: 2 additions & 2 deletions include/ylt/standalone/cinatra/coro_http_request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ inline std::vector<std::pair<int, int>> parse_ranges(std::string_view range_str,
}
}

if (start > 0 && (start >= file_size || start == end)) {
if (start > 0 && (start >= static_cast<int>(file_size) || start == end)) {
// out of range
is_valid = false;
return {};
}

if (end > 0 && end >= file_size) {
if (end > 0 && end >= static_cast<int>(file_size)) {
end = file_size - 1;
}

Expand Down
3 changes: 1 addition & 2 deletions include/ylt/standalone/cinatra/coro_http_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ class coro_http_server {
co_return;
}

for (int i = 0; i < ranges.size(); i++) {
for (size_t i = 0; i < ranges.size(); i++) {
std::string &part_header = multi_heads[i];
r = co_await req.get_conn()->write_data(part_header);
if (!r) {
Expand Down Expand Up @@ -1109,7 +1109,6 @@ class coro_http_server {
asio::ip::address_v6::bytes_type bytes;
unsigned long scope_id = 0;

struct in6_addr addr;
asio::error_code ec;
return asio::detail::socket_ops::inet_pton(ASIO_OS_DEF(AF_INET6),
address.data(), &bytes[0],
Expand Down
2 changes: 1 addition & 1 deletion include/ylt/standalone/cinatra/coro_radix_tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ class radix_tree {
private:
int find_pos(const std::string &str, char target, int start) {
auto i = str.find(target, start);
return i == -1 ? str.size() : i;
return i == std::string::npos ? str.size() : i;
}

std::shared_ptr<radix_tree_node> root;
Expand Down
2 changes: 1 addition & 1 deletion include/ylt/standalone/cinatra/session.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class session {
return session_id_;
}

std::size_t get_time_stamp() {
std::time_t get_time_stamp() {
std::unique_lock<std::mutex> lock(mtx_);
return time_stamp_;
}
Expand Down
4 changes: 2 additions & 2 deletions include/ylt/standalone/cinatra/time_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ constexpr std::string_view YMON[12] = {"Jan", "Feb", "Mar", "Apr",

template <size_t N>
inline void to_int(int num, char c, char *p) {
for (int i = 0; i < N; i++) {
for (size_t i = 0; i < N; i++) {
p[N - 1 - i] = digits[num % 10];
num = num / 10;
}
Expand Down Expand Up @@ -301,7 +301,7 @@ inline std::string_view get_local_time_str(char (&buf)[N], std::time_t t,

char *p = buf;

for (int i = 0; i < format.size(); ++i) {
for (size_t i = 0; i < format.size(); ++i) {
if (format[i] == '%') {
char c = i + 2 < format.size() ? format[i + 2] : '0';
i++;
Expand Down
2 changes: 1 addition & 1 deletion include/ylt/standalone/cinatra/websocket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class websocket {
}

void encode_ws_payload(std::span<char> &data) {
for (int i = 0; i < data.size(); ++i) {
for (size_t i = 0; i < data.size(); ++i) {
data[i] ^= mask_key_[i % 4];
}
}
Expand Down
2 changes: 1 addition & 1 deletion include/ylt/struct_pack/md5_constexpr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct string_literal {
constexpr bool operator!=(
const string_literal<CharType, Size2> &other) const {
if constexpr (Size == Size2) {
for (int i = 0; i < Size; ++i) {
for (size_t i = 0; i < Size; ++i) {
if ((*this)[i] != other[i])
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions include/ylt/util/time_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ constexpr std::string_view YMON[12] = {"Jan", "Feb", "Mar", "Apr",

template <size_t N>
inline void to_int(int num, char c, char *p) {
for (int i = 0; i < N; i++) {
for (size_t i = 0; i < N; i++) {
p[N - 1 - i] = digits[num % 10];
num = num / 10;
}
Expand Down Expand Up @@ -448,7 +448,7 @@ inline std::string_view get_local_time_str(char (&buf)[N], std::time_t t,

char *p = buf;

for (int i = 0; i < format.size(); ++i) {
for (size_t i = 0; i < format.size(); ++i) {
if (format[i] == '%') {
char c = i + 2 < format.size() ? format[i + 2] : '0';
i++;
Expand Down
Loading