From e11be5cdbead955060504da042d68b8f799b8251 Mon Sep 17 00:00:00 2001 From: Jari Sundell Date: Tue, 22 Nov 2011 16:46:59 +0900 Subject: [PATCH] Fixed some compile issues. --- src/display/frame.cc | 20 +++++++++++++------- src/display/frame.h | 3 +++ src/main.cc | 5 ++++- src/rpc/exec_file.cc | 20 +++++++++++--------- src/rpc/scgi_task.cc | 11 +++++++---- src/utils/lockfile.cc | 2 +- 6 files changed, 39 insertions(+), 22 deletions(-) diff --git a/src/display/frame.cc b/src/display/frame.cc index 6e09e35d..8700662a 100644 --- a/src/display/frame.cc +++ b/src/display/frame.cc @@ -38,6 +38,7 @@ #include #include +#include #include #include @@ -332,6 +333,9 @@ Frame::balance_window(uint32_t x, uint32_t y, uint32_t width, uint32_t height) { m_window->mark_dirty(); } +inline Frame::extent_type dynamic_min_height(const Frame::dynamic_type& value) { return value.second.min_height(); } +inline Frame::extent_type dynamic_min_width(const Frame::dynamic_type& value) { return value.second.min_width(); } + inline void Frame::balance_row(uint32_t x, uint32_t y, uint32_t width, uint32_t height) { // Find the size of the static frames. The dynamic frames are added @@ -355,16 +359,17 @@ Frame::balance_row(uint32_t x, uint32_t y, uint32_t width, uint32_t height) { remaining -= bounds.minHeight; } } - + // Sort the dynamic frames by the min size in the direction we are // interested in. Then try to satisfy the largest first, and if we // have any remaining space we can use that to extend it and any // following frames. // // Else if we're short, only give each what they require. - std::sort(dynamicFrames, dynamicFrames + dynamicSize, - rak::greater2(rak::on(rak::const_mem_ref(&dynamic_type::second), rak::const_mem_ref(&Frame::bounds_type::minHeight)), - rak::on(rak::const_mem_ref(&dynamic_type::second), rak::const_mem_ref(&Frame::bounds_type::minHeight)))); + std::stable_sort(dynamicFrames, dynamicFrames + dynamicSize, + std::tr1::bind(std::greater(), + std::tr1::bind(&dynamic_min_height, std::tr1::placeholders::_1), + std::tr1::bind(&dynamic_min_height, std::tr1::placeholders::_2))); bool retry; @@ -436,9 +441,10 @@ Frame::balance_column(uint32_t x, uint32_t y, uint32_t width, uint32_t height) { // following frames. // // Else if we're short, only give each what they require. - std::sort(dynamicFrames, dynamicFrames + dynamicSize, - rak::greater2(rak::on(rak::const_mem_ref(&dynamic_type::second), rak::const_mem_ref(&Frame::bounds_type::minWidth)), - rak::on(rak::const_mem_ref(&dynamic_type::second), rak::const_mem_ref(&Frame::bounds_type::minWidth)))); + std::stable_sort(dynamicFrames, dynamicFrames + dynamicSize, + std::tr1::bind(std::greater(), + std::tr1::bind(&dynamic_min_width, std::tr1::placeholders::_1), + std::tr1::bind(&dynamic_min_width, std::tr1::placeholders::_2))); bool retry; diff --git a/src/display/frame.h b/src/display/frame.h index a9758761..46372952 100644 --- a/src/display/frame.h +++ b/src/display/frame.h @@ -60,6 +60,9 @@ public: bounds_type(extent_type minW, extent_type minH, extent_type maxW, extent_type maxH) : minWidth(minW), minHeight(minH), maxWidth(maxW), maxHeight(maxH) {} + extent_type min_width() const { return minWidth; } + extent_type min_height() const { return minHeight; } + extent_type minWidth; extent_type minHeight; diff --git a/src/main.cc b/src/main.cc index 6c207df7..43474d6e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -36,9 +36,12 @@ #include "config.h" +#define __STDC_FORMAT_MACROS + #include #include #include +#include #include #include #include @@ -954,7 +957,7 @@ handle_sigbus(int signum, siginfo_t* sa, void* ptr) { printf("Torrent name: '%s'.\n", result.download.info()->name().c_str()); printf("File name: '%s'.\n", result.file_path); - printf("File offset: %llu.\n", result.file_offset); + printf("File offset: %" PRIu64 ".\n", result.file_offset); printf("Chunk index: %u.\n", result.chunk_index); printf("Chunk offset: %u.\n", result.chunk_offset); diff --git a/src/rpc/exec_file.cc b/src/rpc/exec_file.cc index 64565c8e..42fe1061 100644 --- a/src/rpc/exec_file.cc +++ b/src/rpc/exec_file.cc @@ -55,17 +55,19 @@ namespace rpc { int ExecFile::execute(const char* file, char* const* argv, int flags) { // Write the execued command and its parameters to the log fd. + int __UNUSED result; + if (m_logFd != -1) { for (char* const* itr = argv; *itr != NULL; itr++) { if (itr == argv) - write(m_logFd, "\n---\n", sizeof("\n---\n")); + result = write(m_logFd, "\n---\n", sizeof("\n---\n")); else - write(m_logFd, " ", 1); + result = write(m_logFd, " ", 1); - write(m_logFd, *itr, std::strlen(*itr)); + result = write(m_logFd, *itr, std::strlen(*itr)); } - write(m_logFd, "\n---\n", sizeof("\n---\n")); + result = write(m_logFd, "\n---\n", sizeof("\n---\n")); } int pipeFd[2]; @@ -87,7 +89,7 @@ ExecFile::execute(const char* file, char* const* argv, int flags) { if (detached_pid != 0) { if (m_logFd != -1) - write(m_logFd, "\n--- Background task ---\n", sizeof("\n--- Background task ---\n")); + result = write(m_logFd, "\n--- Background task ---\n", sizeof("\n--- Background task ---\n")); _exit(0); } @@ -148,8 +150,8 @@ ExecFile::execute(const char* file, char* const* argv, int flags) { ::close(pipeFd[0]); if (m_logFd != -1) { - write(m_logFd, "Captured output:\n", sizeof("Captured output:\n")); - write(m_logFd, m_capture.data(), m_capture.length()); + result = write(m_logFd, "Captured output:\n", sizeof("Captured output:\n")); + result = write(m_logFd, m_capture.data(), m_capture.length()); } } @@ -168,9 +170,9 @@ ExecFile::execute(const char* file, char* const* argv, int flags) { // Check return value? if (m_logFd != -1) { if (status == 0) - write(m_logFd, "\n--- Success ---\n", sizeof("\n--- Success ---\n")); + result = write(m_logFd, "\n--- Success ---\n", sizeof("\n--- Success ---\n")); else - write(m_logFd, "\n--- Error ---\n", sizeof("\n--- Error ---\n")); + result = write(m_logFd, "\n--- Error ---\n", sizeof("\n--- Error ---\n")); } return status; diff --git a/src/rpc/scgi_task.cc b/src/rpc/scgi_task.cc index 4d893bd5..22668dba 100644 --- a/src/rpc/scgi_task.cc +++ b/src/rpc/scgi_task.cc @@ -177,10 +177,12 @@ SCgiTask::event_read() { worker_thread->poll()->insert_write(this); if (m_parent->log_fd() >= 0) { + int __UNUSED result; + // Clean up logging, this is just plain ugly... // write(m_logFd, "\n---\n", sizeof("\n---\n")); - write(m_parent->log_fd(), m_buffer, m_bufferSize); - write(m_parent->log_fd(), "\n---\n", sizeof("\n---\n")); + result = write(m_parent->log_fd(), m_buffer, m_bufferSize); + result = write(m_parent->log_fd(), "\n---\n", sizeof("\n---\n")); } lt_log_print(torrent::LOG_RPC_DEBUG, "---\n%*s\n---", m_bufferSize - std::distance(m_buffer, m_body), m_body); @@ -237,10 +239,11 @@ SCgiTask::receive_write(const char* buffer, uint32_t length) { std::memcpy(m_buffer + headerSize, buffer, length); if (m_parent->log_fd() >= 0) { + int __UNUSED result; // Clean up logging, this is just plain ugly... // write(m_logFd, "\n---\n", sizeof("\n---\n")); - write(m_parent->log_fd(), m_buffer, m_bufferSize); - write(m_parent->log_fd(), "\n---\n", sizeof("\n---\n")); + result = write(m_parent->log_fd(), m_buffer, m_bufferSize); + result = write(m_parent->log_fd(), "\n---\n", sizeof("\n---\n")); } lt_log_print(torrent::LOG_RPC_DEBUG, "---\n%*s\n---", m_bufferSize, m_buffer); diff --git a/src/utils/lockfile.cc b/src/utils/lockfile.cc index c7579a95..7d11d8c9 100644 --- a/src/utils/lockfile.cc +++ b/src/utils/lockfile.cc @@ -99,7 +99,7 @@ Lockfile::try_lock() { if (pos == 0) { ::snprintf(buf + std::strlen(buf), 255, ":+%i\n", ::getpid()); - ::write(fd, buf, std::strlen(buf)); + int __UNUSED result = ::write(fd, buf, std::strlen(buf)); } ::close(fd);