Skip to content

Commit 5103ec7

Browse files
authored
GNU: -Wall -Wextra -Werror; fix related warnings (#143)
1 parent 3317188 commit 5103ec7

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ else(BUILD_TRANTOR_SHARED)
4141
add_library(${PROJECT_NAME} STATIC)
4242
endif(BUILD_TRANTOR_SHARED)
4343

44+
if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
45+
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Werror)
46+
endif()
47+
4448
include(GenerateExportHeader)
4549
generate_export_header(${PROJECT_NAME} EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/exports/trantor/exports.h)
4650

trantor/net/EventLoop.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,11 @@ EventLoop::EventLoop()
6868
currentActiveChannel_(nullptr),
6969
eventHandling_(false),
7070
timerQueue_(new TimerQueue(this)),
71-
threadLocalLoopPtr_(&t_loopInThisThread)
7271
#ifdef __linux__
73-
,
7472
wakeupFd_(createEventfd()),
75-
wakeupChannelPtr_(new Channel(this, wakeupFd_))
73+
wakeupChannelPtr_(new Channel(this, wakeupFd_)),
7674
#endif
75+
threadLocalLoopPtr_(&t_loopInThisThread)
7776
{
7877
if (t_loopInThisThread)
7978
{
@@ -305,10 +304,12 @@ void EventLoop::wakeup()
305304
uint64_t tmp = 1;
306305
#ifdef __linux__
307306
int ret = write(wakeupFd_, &tmp, sizeof(tmp));
307+
(void)ret;
308308
#elif defined _WIN32
309309
poller_->postEvent(1);
310310
#else
311311
int ret = write(wakeupFd_[1], &tmp, sizeof(tmp));
312+
(void)ret;
312313
#endif
313314
}
314315
void EventLoop::wakeupRead()

trantor/net/inner/NormalResolver.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
using namespace trantor;
1414

15-
std::shared_ptr<Resolver> Resolver::newResolver(trantor::EventLoop *loop,
15+
std::shared_ptr<Resolver> Resolver::newResolver(trantor::EventLoop *,
1616
size_t timeout)
1717
{
1818
return std::make_shared<NormalResolver>(timeout);

trantor/net/inner/TcpConnectionImpl.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,7 @@ void TcpConnectionImpl::sendFileInLoop(const BufferNodePtr &filePtr)
14301430
{
14311431
filePtr->fileBytesToSend_ -= nSend;
14321432
filePtr->offset_ += static_cast<off_t>(nSend);
1433-
if (static_cast<size_t>(nSend) < n)
1433+
if (static_cast<size_t>(nSend) < static_cast<size_t>(n))
14341434
{
14351435
if (!ioChannelPtr_->isWriting())
14361436
{
@@ -1559,12 +1559,12 @@ TcpConnectionImpl::TcpConnectionImpl(EventLoop *loop,
15591559
bool isServer,
15601560
bool validateCert,
15611561
const std::string &hostname)
1562-
: loop_(loop),
1562+
: isEncrypted_(true),
1563+
loop_(loop),
15631564
ioChannelPtr_(new Channel(loop, socketfd)),
15641565
socketPtr_(new Socket(socketfd)),
15651566
localAddr_(localAddr),
1566-
peerAddr_(peerAddr),
1567-
isEncrypted_(true)
1567+
peerAddr_(peerAddr)
15681568
{
15691569
LOG_TRACE << "new connection:" << peerAddr.toIpPort() << "->"
15701570
<< localAddr.toIpPort();

trantor/net/inner/TimerQueue.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static void resetTimerfd(int timerfd, const TimePoint &expiration)
6565
// LOG_SYSERR << "timerfd_settime()";
6666
}
6767
}
68-
static void readTimerfd(int timerfd, const TimePoint &now)
68+
static void readTimerfd(int timerfd, const TimePoint &)
6969
{
7070
uint64_t howmany;
7171
ssize_t n = ::read(timerfd, &howmany, sizeof howmany);

0 commit comments

Comments
 (0)