Minor warning fixes.

This commit is contained in:
levlam 2021-10-18 15:37:21 +03:00
parent 81b38d5607
commit 01976bed53
11 changed files with 19 additions and 15 deletions

View File

@ -42,11 +42,11 @@ class LambdaGuard final : public Guard {
}
LambdaGuard &operator=(LambdaGuard &&other) = delete;
void dismiss() {
void dismiss() override {
dismissed_ = true;
}
~LambdaGuard() {
~LambdaGuard() override {
if (!dismissed_) {
func_();
}

View File

@ -128,6 +128,9 @@ struct LogOptions {
}
LogOptions &operator=(const LogOptions &other) {
if (this == &other) {
return *this;
}
level = other.level.load();
fix_newlines = other.fix_newlines;
add_info = other.add_info;

View File

@ -407,7 +407,7 @@ static Status create_local_lock(const string &path, int32 &max_tries) {
}
}
Status FileFd::lock(const LockFlags flags, const string &path, int32 max_tries) {
Status FileFd::lock(LockFlags flags, const string &path, int32 max_tries) {
if (max_tries <= 0) {
return Status::Error("Can't lock file: wrong max_tries");
}

View File

@ -45,7 +45,7 @@ class FileFd {
Result<size_t> pread(MutableSlice slice, int64 offset) const TD_WARN_UNUSED_RESULT;
enum class LockFlags { Write, Read, Unlock };
Status lock(const LockFlags flags, const string &path, int32 max_tries) TD_WARN_UNUSED_RESULT;
Status lock(LockFlags flags, const string &path, int32 max_tries) TD_WARN_UNUSED_RESULT;
static void remove_local_lock(const string &path);
PollableFdInfo &get_poll_info();

View File

@ -489,7 +489,7 @@ class SocketFdImpl {
TRY_STATUS(get_pending_error());
}
int native_fd = get_native_fd().socket();
CHECK(slice.size() > 0);
CHECK(!slice.empty());
auto read_res = detail::skip_eintr([&] { return ::read(native_fd, slice.begin(), slice.size()); });
auto read_errno = errno;
if (read_res >= 0) {

View File

@ -59,7 +59,7 @@ class UdpSocketReceiveHelper {
message_header.dwFlags = 0;
}
void from_native(WSAMSG &message_header, size_t message_size, UdpMessage &message) {
static void from_native(WSAMSG &message_header, size_t message_size, UdpMessage &message) {
message.address.init_sockaddr(reinterpret_cast<sockaddr *>(message_header.name), message_header.namelen).ignore();
message.error = Status::OK();
@ -387,7 +387,7 @@ class UdpSocketReceiveHelper {
message_header.msg_flags = 0;
}
void from_native(msghdr &message_header, size_t message_size, UdpSocketFd::InboundMessage &message) {
static void from_native(msghdr &message_header, size_t message_size, UdpSocketFd::InboundMessage &message) {
#if TD_LINUX
cmsghdr *cmsg;
sock_extended_err *ee = nullptr;

View File

@ -96,7 +96,7 @@ void EventFdLinux::acquire() {
auto slice = MutableSlice(reinterpret_cast<char *>(&res), sizeof(res));
auto native_fd = impl_->info.native_fd().fd();
auto result = [&]() -> Result<size_t> {
CHECK(slice.size() > 0);
CHECK(!slice.empty());
auto read_res = detail::skip_eintr([&] { return ::read(native_fd, slice.begin(), slice.size()); });
auto read_errno = errno;
if (read_res >= 0) {

View File

@ -26,7 +26,7 @@ class EventFdLinux final : public EventFdBase {
EventFdLinux();
EventFdLinux(EventFdLinux &&) noexcept;
EventFdLinux &operator=(EventFdLinux &&) noexcept;
~EventFdLinux();
~EventFdLinux() override;
void init() final;

View File

@ -72,7 +72,8 @@ class ThreadPthread {
return std::forward<T>(v);
}
int do_pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg);
static int do_pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *),
void *arg);
static void *run_thread(void *ptr) {
ThreadIdGuard thread_id_guard;

View File

@ -74,7 +74,7 @@ static void set_handler(struct sigaction &act, decltype(act.sa_sigaction) handle
act.sa_flags |= SA_SIGINFO;
}
template <class F>
static Status set_signal_handler_impl(vector<int> signals, F func) {
static Status set_signal_handler_impl(vector<int> &&signals, F func) {
struct sigaction act;
std::memset(&act, '\0', sizeof(act));
@ -123,7 +123,7 @@ static void signal_handler_func(int sig) {
handler(sig);
}
static Status set_signal_handler_impl(vector<int> signals, void (*func)(int sig)) {
static Status set_signal_handler_impl(vector<int> &&signals, void (*func)(int sig)) {
for (auto signal : signals) {
CHECK(0 <= signal && signal < NSIG);
if (func != SIG_IGN && func != SIG_DFL) {
@ -296,7 +296,7 @@ void signal_safe_write_signal_number(int sig, bool add_header) {
}
void signal_safe_write_pointer(void *p, bool add_header) {
std::uintptr_t addr = reinterpret_cast<std::uintptr_t>(p);
auto addr = reinterpret_cast<std::uintptr_t>(p);
char buf[100];
char *end = buf + sizeof(buf);
char *ptr = end;

View File

@ -26,7 +26,7 @@ namespace td {
namespace {
void print_backtrace(void) {
void print_backtrace() {
#if TD_PORT_WINDOWS
void *buffer[128];
USHORT nptrs = CaptureStackBackTrace(0, 128, buffer, nullptr);
@ -48,7 +48,7 @@ void print_backtrace(void) {
signal_safe_write("-------------------------------\n", false);
}
void print_backtrace_gdb(void) {
void print_backtrace_gdb() {
#if TD_LINUX || TD_FREEBSD
char pid_buf[30];
char *pid_buf_begin = pid_buf + sizeof(pid_buf);