From c7e0f35d106ce07cbb48d8f11e94a9fa3ea6f061 Mon Sep 17 00:00:00 2001 From: marsevilspirit Date: Thu, 16 Jan 2025 14:25:28 +0800 Subject: [PATCH] format --- src/kiwi.cc | 2 +- src/net/epoll_event.cc | 6 +++--- src/net/kqueue_event.cc | 2 +- src/net/listen_socket.cc | 2 +- src/net/timer.cc | 4 +--- src/storage/src/debug.h | 3 +-- src/storage/src/options_helper.h | 2 +- 7 files changed, 9 insertions(+), 12 deletions(-) diff --git a/src/kiwi.cc b/src/kiwi.cc index 3eac895..ed8ff95 100644 --- a/src/kiwi.cc +++ b/src/kiwi.cc @@ -89,7 +89,7 @@ bool KiwiDB::ParseArgs(int argc, char* argv[]) { return false; } if (options_.GetConfigName().empty() && argc > 1 && argv[1] != nullptr) { - struct stat st{}; + struct stat st {}; if (stat(argv[1], &st) == 0 && S_ISREG(st.st_mode) && ::access(argv[1], R_OK) == 0) { options_.SetConfigName(argv[1]); argc = argc - 1; diff --git a/src/net/epoll_event.cc b/src/net/epoll_event.cc index fbd7514..c83413c 100644 --- a/src/net/epoll_event.cc +++ b/src/net/epoll_event.cc @@ -42,7 +42,7 @@ bool EpollEvent::Init() { } void EpollEvent::AddEvent(uint64_t id, int fd, int mask) { - struct epoll_event ev{}; + struct epoll_event ev {}; ev.events = mask; ev.data.u64 = id; if (epoll_ctl(EvFd(), EPOLL_CTL_ADD, fd, &ev) == -1) { @@ -61,7 +61,7 @@ void EpollEvent::EventPoll() { } void EpollEvent::AddWriteEvent(uint64_t id, int fd) { - struct epoll_event ev{}; + struct epoll_event ev {}; ev.events = EVENT_WRITE; ev.data.u64 = id; if (mode_ & EVENT_MODE_READ) { // If it is a read multiplex, modify the event @@ -77,7 +77,7 @@ void EpollEvent::AddWriteEvent(uint64_t id, int fd) { } void EpollEvent::DelWriteEvent(uint64_t id, int fd) { - struct epoll_event ev{}; + struct epoll_event ev {}; ev.data.u64 = id; if (mode_ & EVENT_MODE_READ) { // If it is a read multiplex, modify the event to rea ev.events = EVENT_READ; diff --git a/src/net/kqueue_event.cc b/src/net/kqueue_event.cc index 1178f88..072548e 100644 --- a/src/net/kqueue_event.cc +++ b/src/net/kqueue_event.cc @@ -92,7 +92,7 @@ void KqueueEvent::EventPoll() { void KqueueEvent::EventRead() { struct kevent events[eventsSize]; struct timespec *pTimeout = nullptr; - struct timespec timeout{}; + struct timespec timeout {}; if (timer_) { pTimeout = &timeout; int waitInterval = static_cast(timer_->Interval()); diff --git a/src/net/listen_socket.cc b/src/net/listen_socket.cc index ca3f183..093ef8e 100644 --- a/src/net/listen_socket.cc +++ b/src/net/listen_socket.cc @@ -20,7 +20,7 @@ const int ListenSocket::LISTENQ = 1024; bool ListenSocket::REUSE_PORT = true; int ListenSocket::OnReadable(const std::shared_ptr &conn, std::string *readBuff) { - struct sockaddr_in clientAddr{}; + struct sockaddr_in clientAddr {}; auto newConnFd = Accept(&clientAddr); if (newConnFd == 0) { ERROR("ListenSocket fd:{},Accept error:{}", Fd(), errno); diff --git a/src/net/timer.cc b/src/net/timer.cc index db651b1..6394972 100644 --- a/src/net/timer.cc +++ b/src/net/timer.cc @@ -23,9 +23,7 @@ int64_t Timer::AddTask(const std::shared_ptr& task) { void Timer::RePushTask() { for (const auto& task : list_) { task->Next(); - { - queue_.push(task); - } + { queue_.push(task); } } list_.clear(); } diff --git a/src/storage/src/debug.h b/src/storage/src/debug.h index 47548db..0e7da3d 100644 --- a/src/storage/src/debug.h +++ b/src/storage/src/debug.h @@ -9,6 +9,5 @@ # define TRACE(M, ...) fprintf(stderr, "[TRACE] (%s:%d) " M "\n", __FILE__, __LINE__, ##__VA_ARGS__) #else # define TRACE(M, ...) \ - { \ - } + {} #endif // NDEBUG diff --git a/src/storage/src/options_helper.h b/src/storage/src/options_helper.h index c5fd7bb..74c02a5 100644 --- a/src/storage/src/options_helper.h +++ b/src/storage/src/options_helper.h @@ -29,7 +29,7 @@ struct MemberTypeInfo { // http://en.cppreference.com/w/cpp/concept/StandardLayoutType // https://gist.github.com/graphitemaster/494f21190bb2c63c5516 template -inline int offset_of(T1 T2::* member) { +inline int offset_of(T1 T2::*member) { static T2 obj; return int(size_t(&(obj.*member)) - size_t(&obj)); }