diff --git a/src/kiwi.cc b/src/kiwi.cc index ed8ff95..3eac895 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 c83413c..fbd7514 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 072548e..1178f88 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 093ef8e..ca3f183 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 6394972..db651b1 100644 --- a/src/net/timer.cc +++ b/src/net/timer.cc @@ -23,7 +23,9 @@ 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 0e7da3d..47548db 100644 --- a/src/storage/src/debug.h +++ b/src/storage/src/debug.h @@ -9,5 +9,6 @@ # 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 74c02a5..c5fd7bb 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)); }