Skip to content

Commit

Permalink
Minor warning fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
levlam committed Oct 18, 2021
1 parent 81b38d5 commit 01976be
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 15 deletions.
4 changes: 2 additions & 2 deletions tdutils/td/utils/ScopeGuard.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_();
}
Expand Down
3 changes: 3 additions & 0 deletions tdutils/td/utils/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tdutils/td/utils/port/FileFd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
2 changes: 1 addition & 1 deletion tdutils/td/utils/port/FileFd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion tdutils/td/utils/port/SocketFd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions tdutils/td/utils/port/UdpSocketFd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tdutils/td/utils/port/detail/EventFdLinux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion tdutils/td/utils/port/detail/EventFdLinux.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class EventFdLinux final : public EventFdBase {
EventFdLinux();
EventFdLinux(EventFdLinux &&) noexcept;
EventFdLinux &operator=(EventFdLinux &&) noexcept;
~EventFdLinux();
~EventFdLinux() override;

void init() final;

Expand Down
3 changes: 2 additions & 1 deletion tdutils/td/utils/port/detail/ThreadPthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions tdutils/td/utils/port/signals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions tdutils/td/utils/port/stacktrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 01976be

Please sign in to comment.