projects
/
m6w6
/
libmemcached
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
|
github
raw
|
patch
|
inline
| side by side (parent:
0f27cca
)
clang-tidy
author
Michael Wallner
<mike@php.net>
Fri, 23 Oct 2020 13:32:30 +0000
(15:32 +0200)
committer
Michael Wallner
<mike@php.net>
Fri, 23 Oct 2020 13:32:30 +0000
(15:32 +0200)
15 files changed:
test/lib/Cluster.hpp
patch
|
blob
|
history
test/lib/Connection.cpp
patch
|
blob
|
history
test/lib/Connection.hpp
patch
|
blob
|
history
test/lib/ForkAndExec.cpp
patch
|
blob
|
history
test/lib/MemcachedCluster.cpp
patch
|
blob
|
history
test/lib/MemcachedCluster.hpp
patch
|
blob
|
history
test/lib/Retry.cpp
patch
|
blob
|
history
test/lib/ReturnMatcher.cpp
patch
|
blob
|
history
test/lib/ReturnMatcher.hpp
patch
|
blob
|
history
test/lib/Server.hpp
patch
|
blob
|
history
test/lib/Shell.cpp
patch
|
blob
|
history
test/lib/Shell.hpp
patch
|
blob
|
history
test/lib/common.cpp
patch
|
blob
|
history
test/lib/common.hpp
patch
|
blob
|
history
test/lib/random.cpp
patch
|
blob
|
history
diff --git
a/test/lib/Cluster.hpp
b/test/lib/Cluster.hpp
index c6c0cb926aa776b6d1672d4f4d51d4d128eba83a..1cc00ac89539e1931708fc58daf07b343b837459 100644
(file)
--- a/
test/lib/Cluster.hpp
+++ b/
test/lib/Cluster.hpp
@@
-27,11
+27,11
@@
public:
Cluster(const Cluster &c) = delete;
Cluster &operator=(const Cluster &c) = delete;
Cluster(const Cluster &c) = delete;
Cluster &operator=(const Cluster &c) = delete;
- Cluster(Cluster &&c)
+ Cluster(Cluster &&c)
noexcept
: proto{} {
*this = move(c);
};
: proto{} {
*this = move(c);
};
- Cluster &operator=(Cluster &&c) {
+ Cluster &operator=(Cluster &&c)
noexcept
{
count = exchange(c.count, 0);
proto = exchange(c.proto, Server{});
cluster = exchange(c.cluster, {});
count = exchange(c.count, 0);
proto = exchange(c.proto, Server{});
cluster = exchange(c.cluster, {});
diff --git
a/test/lib/Connection.cpp
b/test/lib/Connection.cpp
index 05440723455bfc787caba43a18cb78c800560447..b6df553b1ca5f166c259cb29118b6e2ded18b036 100644
(file)
--- a/
test/lib/Connection.cpp
+++ b/
test/lib/Connection.cpp
@@
-2,15
+2,18
@@
#include <cerrno>
#include <sys/poll.h>
#include <cerrno>
#include <sys/poll.h>
-#include <fcntl.h>
#include <unistd.h>
#include <unistd.h>
+#if !(HAVE_SOCK_NONBLOCK && HAVE_SOCK_CLOEXEC)
+# include <fcntl.h>
+# define SOCK_NONBLOCK O_NONBLOCK
+# define SOCK_CLOEXEC O_CLOEXEC
+#endif
+
static inline int socket_ex(int af, int so, int pf, int fl) {
#if HAVE_SOCK_NONBLOCK && HAVE_SOCK_CLOEXEC
return socket(af, so | fl, pf);
#else
static inline int socket_ex(int af, int so, int pf, int fl) {
#if HAVE_SOCK_NONBLOCK && HAVE_SOCK_CLOEXEC
return socket(af, so | fl, pf);
#else
-# define SOCK_NONBLOCK O_NONBLOCK
-# define SOCK_CLOEXEC O_CLOEXEC
auto sock = socket(af, so, pf);
if (0 <= sock) {
if (0 > fcntl(sock, F_SETFL, fl | fcntl(sock, F_GETFL))) {
auto sock = socket(af, so, pf);
if (0 <= sock) {
if (0 > fcntl(sock, F_SETFL, fl | fcntl(sock, F_GETFL))) {
@@
-186,7
+189,7
@@
bool Connection::open() {
string Connection::error(const initializer_list<string> &args) {
stringstream ss;
string Connection::error(const initializer_list<string> &args) {
stringstream ss;
- for (auto &arg : args) {
+ for (
const
auto &arg : args) {
ss << arg;
}
ss << arg;
}
diff --git
a/test/lib/Connection.hpp
b/test/lib/Connection.hpp
index 380116e6bdc9bd5aaa11783cf69d8c40d5843a4d..f087a697423f38b9d159d360ce92080159441032 100644
(file)
--- a/
test/lib/Connection.hpp
+++ b/
test/lib/Connection.hpp
@@
-51,7
+51,7
@@
private:
UNIX = sizeof(sockaddr_un),
INET = sizeof(sockaddr_in),
INET6 = sizeof(sockaddr_in6)
UNIX = sizeof(sockaddr_un),
INET = sizeof(sockaddr_in),
INET6 = sizeof(sockaddr_in6)
- } size;
+ } size
= NONE
;
bool connected{false};
static string error(const initializer_list<string> &args);
bool connected{false};
static string error(const initializer_list<string> &args);
diff --git
a/test/lib/ForkAndExec.cpp
b/test/lib/ForkAndExec.cpp
index e182c7c47dcf55c11f493c71ccc207c220054a0b..ac30dd0282195e4430019d61901bf9abd1078d0e 100644
(file)
--- a/
test/lib/ForkAndExec.cpp
+++ b/
test/lib/ForkAndExec.cpp
@@
-1,6
+1,5
@@
#include "ForkAndExec.hpp"
#include "ForkAndExec.hpp"
-#include <cerrno>
#include <cstdio>
#include <fcntl.h>
#include <cstdio>
#include <fcntl.h>
diff --git
a/test/lib/MemcachedCluster.cpp
b/test/lib/MemcachedCluster.cpp
index 06e2c7f1b97d3cfac6f49366d723b4fa12a05d6a..f94e86ca80d276534ff6164ec4ac274fa98ecb99 100644
(file)
--- a/
test/lib/MemcachedCluster.cpp
+++ b/
test/lib/MemcachedCluster.cpp
@@
-46,7
+46,7
@@
void MemcachedCluster::init() {
}
MemcachedCluster::~MemcachedCluster() {
}
MemcachedCluster::~MemcachedCluster() {
- if (memcmp(&memc, &empty_memc, sizeof(memc))) {
+ if (
!!
memcmp(&memc, &empty_memc, sizeof(memc))) {
memcached_free(&memc);
}
}
memcached_free(&memc);
}
}
@@
-71,13
+71,13
@@
MemcachedCluster::MemcachedCluster(Cluster &&cluster_, behaviors_t to_set_)
init();
}
init();
}
-MemcachedCluster::MemcachedCluster(MemcachedCluster &&mc)
+MemcachedCluster::MemcachedCluster(MemcachedCluster &&mc)
noexcept
: cluster{Server{}}
{
*this = move(mc);
}
: cluster{Server{}}
{
*this = move(mc);
}
-MemcachedCluster &MemcachedCluster::operator=(MemcachedCluster &&mc) {
+MemcachedCluster &MemcachedCluster::operator=(MemcachedCluster &&mc)
noexcept
{
cluster = move(mc.cluster);
memcached_clone(&memc, &mc.memc);
returns = ReturnMatcher{&memc};
cluster = move(mc.cluster);
memcached_clone(&memc, &mc.memc);
returns = ReturnMatcher{&memc};
@@
-146,7
+146,7
@@
void MemcachedCluster::enableReplication() {
MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, memcached_server_count(&memc) - 1));
}
MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, memcached_server_count(&memc) - 1));
}
-void MemcachedCluster::killOneServer() {
+void MemcachedCluster::killOneServer()
const
{
const auto &servers = cluster.getServers();
const auto &victim = servers[random_num(0UL, servers.size() - 1)];
::kill(victim.getPid(), SIGKILL);
const auto &servers = cluster.getServers();
const auto &victim = servers[random_num(0UL, servers.size() - 1)];
::kill(victim.getPid(), SIGKILL);
diff --git
a/test/lib/MemcachedCluster.hpp
b/test/lib/MemcachedCluster.hpp
index 202d878db2407666fb72b36a4aed2dc4f443d436..dcda9ddd72afb30744ac70acd939ac0bad4b84b6 100644
(file)
--- a/
test/lib/MemcachedCluster.hpp
+++ b/
test/lib/MemcachedCluster.hpp
@@
-35,13
+35,12
@@
public:
MemcachedCluster(const MemcachedCluster &) = delete;
MemcachedCluster &operator=(const MemcachedCluster &) = delete;
MemcachedCluster(const MemcachedCluster &) = delete;
MemcachedCluster &operator=(const MemcachedCluster &) = delete;
- MemcachedCluster(MemcachedCluster &&mc);
- MemcachedCluster &operator=(MemcachedCluster &&mc);
+ MemcachedCluster(MemcachedCluster &&mc)
noexcept
;
+ MemcachedCluster &operator=(MemcachedCluster &&mc)
noexcept
;
void enableBinaryProto(bool enable = true);
void enableBuffering(bool enable = true);
void enableReplication();
void enableBinaryProto(bool enable = true);
void enableBuffering(bool enable = true);
void enableReplication();
- void enableUdp(bool enable = true);
void flush();
static MemcachedCluster mixed();
void flush();
static MemcachedCluster mixed();
@@
-53,7
+52,7
@@
public:
static MemcachedCluster sasl();
#endif
static MemcachedCluster sasl();
#endif
- void killOneServer();
+ void killOneServer()
const
;
private:
behaviors_t to_set;
private:
behaviors_t to_set;
diff --git
a/test/lib/Retry.cpp
b/test/lib/Retry.cpp
index 71fde0e046f7cc03a25d568b0b3893175dc31dc3..d8061e314c7d61cda323965ec7bfb81ce61d2476 100644
(file)
--- a/
test/lib/Retry.cpp
+++ b/
test/lib/Retry.cpp
@@
-15,7
+15,7
@@
bool Retry::operator()() {
return true;
}
this_thread::sleep_for(dur);
return true;
}
this_thread::sleep_for(dur);
- dur
*= 1.2
;
+ dur
+= dur/10
;
}
return false;
}
return false;
diff --git
a/test/lib/ReturnMatcher.cpp
b/test/lib/ReturnMatcher.cpp
index 863945e827961549cfad4b68eca83968c269262f..82f42d6573f3224deceb2497806a090852a69c79 100644
(file)
--- a/
test/lib/ReturnMatcher.cpp
+++ b/
test/lib/ReturnMatcher.cpp
@@
-1,11
+1,5
@@
#include "ReturnMatcher.hpp"
#include "ReturnMatcher.hpp"
-ReturnMatcher &ReturnMatcher::operator=(ReturnMatcher &&rm) {
- memc = exchange(rm.memc, nullptr);
- expected = rm.expected;
- return *this;
-}
-
bool ReturnMatcher::match(const memcached_return_t &arg) const {
return arg == expected;
}
bool ReturnMatcher::match(const memcached_return_t &arg) const {
return arg == expected;
}
@@
-23,6
+17,3
@@
string ReturnMatcher::describe() const {
+ "\n actual: " + memcached_last_error_message(memc);
}
+ "\n actual: " + memcached_last_error_message(memc);
}
-ReturnMatcher::ReturnMatcher(ReturnMatcher &&rm) {
- *this = move(rm);
-}
diff --git
a/test/lib/ReturnMatcher.hpp
b/test/lib/ReturnMatcher.hpp
index 5de5b3b28e348cb4dcf8ba55991581d1d279fe78..a52253197f01dc013676e8cd4e5d8c4bb86b4aa1 100644
(file)
--- a/
test/lib/ReturnMatcher.hpp
+++ b/
test/lib/ReturnMatcher.hpp
@@
-26,9
+26,6
@@
public:
ReturnMatcher(const ReturnMatcher &) = default;
ReturnMatcher(const ReturnMatcher &) = default;
- ReturnMatcher(ReturnMatcher &&rm);
- ReturnMatcher &operator=(ReturnMatcher &&rm);
-
bool match(const memcached_return_t &arg) const override;
ReturnMatcher success();
ReturnMatcher operator()(memcached_return_t expected_);
bool match(const memcached_return_t &arg) const override;
ReturnMatcher success();
ReturnMatcher operator()(memcached_return_t expected_);
diff --git
a/test/lib/Server.hpp
b/test/lib/Server.hpp
index 5e263267b1cdd252d61180d9d8808fe0c3061701..9b1d4a7324c2334800cc075597e237b455e1f494 100644
(file)
--- a/
test/lib/Server.hpp
+++ b/
test/lib/Server.hpp
@@
-36,8
+36,10
@@
public:
Server(const Server &s);
Server &operator=(const Server &s);
Server(const Server &s);
Server &operator=(const Server &s);
- Server(Server &&s) { *this = move(s); };
- Server &operator=(Server &&s) {
+ Server(Server &&s) noexcept {
+ *this = move(s);
+ };
+ Server &operator=(Server &&s) noexcept {
binary = exchange(s.binary, "false");
args = exchange(s.args, {});
pid = exchange(s.pid, 0);
binary = exchange(s.binary, "false");
args = exchange(s.args, {});
pid = exchange(s.pid, 0);
@@
-89,7
+91,7
@@
private:
optional<string> handleArg(vector<char *> &arr, const string &arg, const arg_func_t &next_arg);
};
optional<string> handleArg(vector<char *> &arr, const string &arg, const arg_func_t &next_arg);
};
-inline ostream &operator<<(ostream &out, const socket_or_port_t sop) {
+inline ostream &operator<<(ostream &out, const socket_or_port_t
&
sop) {
if (holds_alternative<string>(sop)) {
out << get<string>(sop);
} else {
if (holds_alternative<string>(sop)) {
out << get<string>(sop);
} else {
diff --git
a/test/lib/Shell.cpp
b/test/lib/Shell.cpp
index cd3017acb0a2cb4a323d60c0975a6fb8f9d8c9fd..4d669095d83ca556a0a2a6ec29464f021ea944f9 100644
(file)
--- a/
test/lib/Shell.cpp
+++ b/
test/lib/Shell.cpp
@@
-1,7
+1,6
@@
#include "Shell.hpp"
#include <cstdlib>
#include "Shell.hpp"
#include <cstdlib>
-#include <unistd.h>
bool Shell::run(const string &command_, string &output) {
auto command = prepareCommand(command_);
bool Shell::run(const string &command_, string &output) {
auto command = prepareCommand(command_);
@@
-47,8
+46,8
@@
Shell::Shell(bool redirect_stderr)
}
}
}
}
-Shell::Shell(
const string &
prefix_, bool redirect_stderr)
-: prefix{
prefix_
}
+Shell::Shell(
string
prefix_, bool redirect_stderr)
+: prefix{
move(prefix_)
}
, redirect{redirect_stderr}
{
if (!system(nullptr)) {
, redirect{redirect_stderr}
{
if (!system(nullptr)) {
diff --git
a/test/lib/Shell.hpp
b/test/lib/Shell.hpp
index a1496bb5eb536fcb366ee262c9d408504a5ded21..515bf1b59b40d94f0779910cad1715069bd01b7f 100644
(file)
--- a/
test/lib/Shell.hpp
+++ b/
test/lib/Shell.hpp
@@
-20,7
+20,7
@@
class Shell {
public:
explicit Shell(bool redirect_stderr = true);
class Shell {
public:
explicit Shell(bool redirect_stderr = true);
- explicit Shell(
const string &
prefix, bool redirect_stderr = true);
+ explicit Shell(
string
prefix, bool redirect_stderr = true);
bool run(const string &command, string &output);
bool run(const string &command);
bool run(const string &command, string &output);
bool run(const string &command);
diff --git
a/test/lib/common.cpp
b/test/lib/common.cpp
index 04dd79d650dfe66633068e34ee2156b3ab9f24d5..c516a3db03b66de9a57fe812b4677933a5981bb1 100644
(file)
--- a/
test/lib/common.cpp
+++ b/
test/lib/common.cpp
@@
-1,5
+1,4
@@
#include "common.hpp"
#include "common.hpp"
-#include "Connection.hpp"
#include <cstdlib>
#include <cstdlib>
diff --git
a/test/lib/common.hpp
b/test/lib/common.hpp
index a76a1ca8f8c94d80116cc75dabe9d470013f6d58..a0fdf3846208dab4607ef7d9907cd3c6f0b5246e 100644
(file)
--- a/
test/lib/common.hpp
+++ b/
test/lib/common.hpp
@@
-87,8
+87,8
@@
public:
close(fd);
unlink(fn);
}
close(fd);
unlink(fn);
}
- int getFd() const { return fd; }
- const char *getFn() const { return fn; }
+
[[nodiscard]]
int getFd() const { return fd; }
+
[[nodiscard]]
const char *getFn() const { return fn; }
bool put(const char *buf, size_t len) const {
return static_cast<ssize_t>(len) == write(fd, buf, len);
}
bool put(const char *buf, size_t len) const {
return static_cast<ssize_t>(len) == write(fd, buf, len);
}
diff --git
a/test/lib/random.cpp
b/test/lib/random.cpp
index 50cc53db508ed219da16f00d9538554f774f6cf0..6aab887597f087e75b823f24773cf0515845c11d 100644
(file)
--- a/
test/lib/random.cpp
+++ b/
test/lib/random.cpp
@@
-4,17
+4,17
@@
#include <unistd.h> // getpid()
unsigned random_port() {
#include <unistd.h> // getpid()
unsigned random_port() {
- retry:
- auto port = random_num(5000, 32000);
- Connection conn(port);
-
- if (!conn.open()) {
- return port;
- }
- if (!conn.isOpen()) {
- return port;
- }
-
goto retry
;
+ do {
+
auto port = random_num(5000, 32000);
+
Connection conn(port);
+
+
if (!conn.open()) {
+
return port;
+
}
+
if (!conn.isOpen()) {
+
return port;
+
}
+
} while(true)
;
}
string random_port_string(const string &) {
}
string random_port_string(const string &) {