Skip to content

Commit 1f4b639

Browse files
authored
Fix some compilation warnings (#53)
1 parent e4e5a4a commit 1f4b639

19 files changed

+42
-37
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
cmake_minimum_required(VERSION 3.5)
22
project(trantor)
33
add_library(${PROJECT_NAME} STATIC)
4+
# if(MSVC)
5+
# target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WX)
6+
# else()
7+
# target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -pedantic)
8+
# endif()
9+
410
set(TRANTOR_MAJOR_VERSION 1)
511
set(TRANTOR_MINOR_VERSION 0)
612
set(TRANTOR_PATCH_VERSION 0)
@@ -167,4 +173,5 @@ install(
167173
# Install the export set for use with the install-tree
168174
install(EXPORT TrantorTargets
169175
DESTINATION "${INSTALL_TRANTOR_CMAKE_DIR}"
176+
NAMESPACE Trantor::
170177
COMPONENT dev)

cmake/templates/TrantorConfig.cmake.in

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,15 @@
99
@PACKAGE_INIT@
1010

1111
# Compute paths
12-
add_library(Trantor::Trantor INTERFACE IMPORTED GLOBAL)
1312

1413
# Our library dependencies (contains definitions for IMPORTED targets)
1514
get_filename_component(TRANTOR_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
16-
if(NOT TARGET trantor)
15+
if(NOT TARGET Trantor::Trantor)
1716
include("${TRANTOR_CMAKE_DIR}/TrantorTargets.cmake")
17+
set_target_properties(Trantor::trantor PROPERTIES IMPORTED_GLOBAL TRUE)
18+
add_library(Trantor::Trantor ALIAS Trantor::trantor)
1819
endif()
1920

20-
# These are IMPORTED targets created by TrantorTargets.cmake
21-
target_link_libraries(Trantor::Trantor INTERFACE trantor)
22-
23-
2421
set(TRANTOR_FOUND TRUE)
25-
get_target_property(TRANTOR_INCLUDE_DIRS trantor INTERFACE_INCLUDE_DIRECTORIES)
26-
set(TRANTOR_LIBRARIES trantor)
22+
get_target_property(TRANTOR_INCLUDE_DIRS Trantor::Trantor INTERFACE_INCLUDE_DIRECTORIES)
23+
set(TRANTOR_LIBRARIES Trantor::Trantor)

trantor/net/TcpClient.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ using namespace std::placeholders;
3737

3838
namespace trantor
3939
{
40-
void removeConnector(const ConnectorPtr &connector)
40+
void removeConnector(const ConnectorPtr &)
4141
{
4242
// connector->
4343
}

trantor/net/TcpServer.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,11 @@ TcpServer::TcpServer(EventLoop *loop,
3030
: _loop(loop),
3131
_acceptorPtr(new Acceptor(loop, address, reUseAddr, reUsePort)),
3232
_serverName(name),
33-
_recvMessageCallback(
34-
[](const TcpConnectionPtr &connectionPtr, MsgBuffer *buffer) {
35-
LOG_ERROR << "unhandled recv message [" << buffer->readableBytes()
36-
<< " bytes]";
37-
buffer->retrieveAll();
38-
})
33+
_recvMessageCallback([](const TcpConnectionPtr &, MsgBuffer *buffer) {
34+
LOG_ERROR << "unhandled recv message [" << buffer->readableBytes()
35+
<< " bytes]";
36+
buffer->retrieveAll();
37+
})
3938
{
4039
_acceptorPtr->setNewConnectionCallback(
4140
std::bind(&TcpServer::newConnection, this, _1, _2));

trantor/net/TcpServer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ class TcpServer : NonCopyable
4141
void start();
4242
void setIoLoopNum(size_t num)
4343
{
44-
assert(num >= 0);
4544
assert(!_started);
4645
_loopPoolPtr = std::make_shared<EventLoopThreadPool>(num);
4746
_loopPoolPtr->start();

trantor/net/inner/AresResolver.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ void AresResolver::onQueryResult(int status,
157157
const std::string& hostname,
158158
const Callback& callback)
159159
{
160-
// LOG_DEBUG << "onQueryResult " << status;
160+
LOG_TRACE << "onQueryResult " << status;
161161
struct sockaddr_in addr;
162162
memset(&addr, 0, sizeof addr);
163163
addr.sin_family = AF_INET;
@@ -177,6 +177,7 @@ void AresResolver::onQueryResult(int status,
177177

178178
void AresResolver::onSockCreate(int sockfd, int type)
179179
{
180+
(void)type;
180181
_loop->assertInLoopThread();
181182
assert(_channels.find(sockfd) == _channels.end());
182183
Channel* channel = new Channel(_loop, sockfd);
@@ -187,6 +188,7 @@ void AresResolver::onSockCreate(int sockfd, int type)
187188

188189
void AresResolver::onSockStateChange(int sockfd, bool read, bool write)
189190
{
191+
(void)write;
190192
_loop->assertInLoopThread();
191193
ChannelList::iterator it = _channels.find(sockfd);
192194
assert(it != _channels.end());
@@ -209,6 +211,7 @@ void AresResolver::ares_host_callback(void* data,
209211
int timeouts,
210212
struct hostent* hostent)
211213
{
214+
(void)timeouts;
212215
QueryData* query = static_cast<QueryData*>(data);
213216

214217
query->_owner->onQueryResult(status,

trantor/net/inner/Channel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,4 +167,4 @@ class Channel : NonCopyable
167167
std::weak_ptr<void> _tie;
168168
bool _tied;
169169
};
170-
}; // namespace trantor
170+
} // namespace trantor

trantor/net/inner/Timer.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,4 @@ bool Timer::operator>(const Timer &t) const
5757
{
5858
return _when > t._when;
5959
}
60-
}; // namespace trantor
60+
} // namespace trantor

trantor/net/inner/Timer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ class Timer : public NonCopyable
6060
static std::atomic<TimerId> _timersCreated;
6161
};
6262

63-
}; // namespace trantor
63+
} // namespace trantor

trantor/net/inner/TimerQueue.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ void readTimerfd(int timerfd, const Date &now)
6666
{
6767
uint64_t howmany;
6868
ssize_t n = ::read(timerfd, &howmany, sizeof howmany);
69-
// LOG_TRACE << "TimerQueue::handleRead() " << howmany << " at " <<
70-
// now.toString();
69+
LOG_TRACE << "TimerQueue::handleRead() " << howmany << " at "
70+
<< now.toFormattedString(true);
7171
if (n != sizeof howmany)
7272
{
73-
// LOG_ERROR << "TimerQueue::handleRead() reads " << n << " bytes
74-
// instead of 8";
73+
LOG_ERROR << "TimerQueue::handleRead() reads " << n
74+
<< " bytes instead of 8";
7575
}
7676
}
7777

trantor/net/inner/TimerQueue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,4 @@ class TimerQueue : NonCopyable
7171
private:
7272
std::unordered_set<uint64_t> _timerIdSet;
7373
};
74-
}; // namespace trantor
74+
} // namespace trantor

trantor/net/inner/poller/EpollPoller.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,13 @@ EpollPoller::EpollPoller(EventLoop *loop) : Poller(loop)
195195
EpollPoller::~EpollPoller()
196196
{
197197
}
198-
void EpollPoller::poll(int timeoutMs, ChannelList *activeChannels)
198+
void EpollPoller::poll(int, ChannelList *)
199199
{
200200
}
201-
void EpollPoller::updateChannel(Channel *channel)
201+
void EpollPoller::updateChannel(Channel *)
202202
{
203203
}
204-
void EpollPoller::removeChannel(Channel *channel)
204+
void EpollPoller::removeChannel(Channel *)
205205
{
206206
}
207207
#endif

trantor/net/inner/poller/KQueue.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,13 @@ KQueue::KQueue(EventLoop *loop) : Poller(loop)
233233
KQueue::~KQueue()
234234
{
235235
}
236-
void KQueue::poll(int timeoutMs, ChannelList *activeChannels)
236+
void KQueue::poll(int, ChannelList *)
237237
{
238238
}
239-
void KQueue::updateChannel(Channel *channel)
239+
void KQueue::updateChannel(Channel *)
240240
{
241241
}
242-
void KQueue::removeChannel(Channel *channel)
242+
void KQueue::removeChannel(Channel *)
243243
{
244244
}
245245
void KQueue::resetAfterFork()

trantor/utils/Date.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,4 +247,4 @@ Date::Date(unsigned int year,
247247
microSecondsSinceEpoch_ = epoch * MICRO_SECONDS_PRE_SEC + microSecond;
248248
}
249249

250-
}; // namespace trantor
250+
} // namespace trantor

trantor/utils/Date.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,4 @@ class Date
147147
private:
148148
int64_t microSecondsSinceEpoch_ = 0;
149149
};
150-
}; // namespace trantor
150+
} // namespace trantor

trantor/utils/Logger.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ Logger::Logger(SourceFile file, int line, LogLevel level, const char *func)
122122
formatTime();
123123
logStream_ << T(logLevelStr[level_], 7) << "[" << func << "] ";
124124
}
125-
Logger::Logger(SourceFile file, int line, bool isSysErr)
125+
Logger::Logger(SourceFile file, int line, bool)
126126
: sourceFile_(file), fileLine_(line), level_(FATAL)
127127
{
128128
formatTime();

trantor/utils/SerialTaskQueue.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ void SerialTaskQueue::waitAllTasksFinished()
5353
});
5454
}
5555

56-
}; // namespace trantor
56+
} // namespace trantor

trantor/utils/SerialTaskQueue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ class SerialTaskQueue : public TaskQueue
5050
EventLoopThread _loopThread;
5151
bool _stop = false;
5252
};
53-
}; // namespace trantor
53+
} // namespace trantor

trantor/utils/TaskQueue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ class TaskQueue : public NonCopyable
4040
fut.get();
4141
};
4242
};
43-
}; // namespace trantor
43+
} // namespace trantor

0 commit comments

Comments
 (0)