Skip to content

Commit c36261a

Browse files
committed
More fixes from clang-tidy.
1 parent 05e16c1 commit c36261a

32 files changed

+41
-62
lines changed

.clang-tidy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
# Only run a few checks for now.
3-
Checks: 'modernize-loop-convert'
3+
Checks: 'performance-*'
44
WarningsAsErrors: ''
55
HeaderFilterRegex: ''
66
AnalyzeTemporaryDtors: false

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
3737
list(APPEND CXX_FLAGS "-Wno-null-dereference")
3838
list(APPEND CXX_FLAGS "-Wno-sign-conversion")
3939
list(APPEND CXX_FLAGS "-Wno-unused-local-typedef")
40-
list(APPEND CXX_FLAGS "-Wno-unused-private-field")
4140
list(APPEND CXX_FLAGS "-Wthread-safety")
4241
list(REMOVE_ITEM CXX_FLAGS "-rdynamic")
4342
endif()

contrib/thrift/ThriftServer.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
using namespace muduo;
88
using namespace muduo::net;
99

10-
ThriftServer::~ThriftServer()
11-
{
12-
}
10+
ThriftServer::~ThriftServer() = default;
1311

1412
void ThriftServer::serve()
1513
{

examples/curl/download.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ class Piece : noncopyable
2323
Piece(const curl::RequestPtr& req,
2424
const FilePtr& out,
2525
const muduo::string& range,
26-
const std::function<void()> done)
26+
std::function<void()> done)
2727
: req_(req),
2828
out_(out),
2929
range_(range),
30-
doneCb_(done)
30+
doneCb_(std::move(done))
3131
{
3232
LOG_INFO << "range: " << range;
3333
req->setRange(range);
@@ -158,7 +158,7 @@ class Downloader : noncopyable
158158
}
159159
pieces_[i].reset(new Piece(req,
160160
out,
161-
range.str().c_str(), // std::string -> muduo::string
161+
range.str(),
162162
std::bind(&Downloader::onDownloadDone, this)));
163163
}
164164
else

examples/fastcgi/fastcgi.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ bool FastCgiCodec::parseAllParams()
8181
return false;
8282
if (paramsStream_.readableBytes() >= nameLen+valueLen)
8383
{
84-
string name = paramsStream_.retrieveAsString(nameLen);
84+
std::string name = paramsStream_.retrieveAsString(nameLen);
8585
params_[name] = paramsStream_.retrieveAsString(valueLen);
8686
}
8787
else

examples/fastcgi/fastcgi.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
#include <muduo/net/TcpConnection.h>
55
#include <map>
66

7-
using muduo::string;
8-
97
// one FastCgiCodec per TcpConnection
108
// both lighttpd and nginx do not implement multiplexing,
119
// so there is no concurrent requests of one connection.
1210
class FastCgiCodec : muduo::noncopyable
1311
{
1412
public:
15-
typedef std::map<string, string> ParamMap;
13+
typedef std::map<std::string, std::string> ParamMap;
1614
typedef std::function<void (const muduo::net::TcpConnectionPtr& conn,
1715
ParamMap&,
1816
muduo::net::Buffer*)> Callback;

examples/idleconnection/echo.cc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,10 @@ void EchoServer::dumpConnectionBuckets() const
8787
{
8888
const Bucket& bucket = *bucketI;
8989
printf("[%d] len = %zd : ", idx, bucket.size());
90-
for (Bucket::const_iterator it = bucket.begin();
91-
it != bucket.end();
92-
++it)
90+
for (const auto& it : bucket)
9391
{
94-
bool connectionDead = (*it)->weakConn_.expired();
95-
printf("%p(%ld)%s, ", get_pointer(*it), it->use_count(),
92+
bool connectionDead = it->weakConn_.expired();
93+
printf("%p(%ld)%s, ", get_pointer(it), it.use_count(),
9694
connectionDead ? " DEAD" : "");
9795
}
9896
puts("");

examples/memcached/server/Item.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
#include <memory>
99

10-
using muduo::string;
11-
using muduo::StringPiece;
12-
1310
namespace muduo
1411
{
1512
namespace net
@@ -37,7 +34,7 @@ class Item : muduo::noncopyable
3734
kCas,
3835
};
3936

40-
static ItemPtr makeItem(StringPiece keyArg,
37+
static ItemPtr makeItem(muduo::StringPiece keyArg,
4138
uint32_t flagsArg,
4239
int exptimeArg,
4340
int valuelen,
@@ -47,7 +44,7 @@ class Item : muduo::noncopyable
4744
//return ItemPtr(new Item(keyArg, flagsArg, exptimeArg, valuelen, casArg));
4845
}
4946

50-
Item(StringPiece keyArg,
47+
Item(muduo::StringPiece keyArg,
5148
uint32_t flagsArg,
5249
int exptimeArg,
5350
int valuelen,
@@ -114,7 +111,7 @@ class Item : muduo::noncopyable
114111

115112
void output(muduo::net::Buffer* out, bool needCas = false) const;
116113

117-
void resetKey(StringPiece k);
114+
void resetKey(muduo::StringPiece k);
118115

119116
private:
120117
int totalLen() const { return keylen_ + valuelen_; }

examples/memcached/server/MemcacheServer.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ MemcacheServer::MemcacheServer(muduo::net::EventLoop* loop, const Options& optio
2929
std::bind(&MemcacheServer::onConnection, this, _1));
3030
}
3131

32-
MemcacheServer::~MemcacheServer()
33-
{
34-
}
32+
MemcacheServer::~MemcacheServer() = default;
3533

3634
void MemcacheServer::start()
3735
{

examples/procmon/plot.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class Plot : muduo::noncopyable
2828
const int height_;
2929
const int totalSeconds_;
3030
const int samplingPeriod_;
31-
const gdImagePtr image_;
32-
const MyGdFontPtr font_;
31+
gdImagePtr const image_;
32+
MyGdFontPtr const font_;
3333
const int fontWidth_;
3434
const int fontHeight_;
3535
const int background_;

0 commit comments

Comments
 (0)