You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bc...@apache.org on 2018/04/11 01:48:32 UTC
[trafficserver] branch master updated: Ran clang-tidy with
readability-braces-around-statements
This is an automated email from the ASF dual-hosted git repository.
bcall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 711c4f4 Ran clang-tidy with readability-braces-around-statements
711c4f4 is described below
commit 711c4f4be103b44c1971196297c373d7684a0db5
Author: Bryan Call <bc...@apache.org>
AuthorDate: Mon Apr 9 14:37:18 2018 -0700
Ran clang-tidy with readability-braces-around-statements
---
cmd/traffic_layout/engine.cc | 9 +-
cmd/traffic_layout/file_system.cc | 38 +++++---
cmd/traffic_layout/info.cc | 5 +-
cmd/traffic_layout/traffic_layout.cc | 3 +-
iocore/dns/DNSConnection.cc | 3 +-
iocore/eventsystem/UnixEThread.cc | 10 ++-
iocore/hostdb/HostDB.cc | 3 +-
iocore/net/SNIActionPerformer.cc | 7 +-
iocore/net/SSLClientUtils.cc | 4 +-
iocore/net/SSLConfig.cc | 3 +-
iocore/net/SSLNetVConnection.cc | 3 +-
iocore/net/SSLSNIConfig.cc | 17 ++--
iocore/net/SSLSessionCache.cc | 6 +-
iocore/net/SSLUtils.cc | 6 +-
iocore/net/UnixNet.cc | 21 +++--
iocore/net/UnixNetProcessor.cc | 3 +-
lib/ts/BufferWriterFormat.cc | 122 +++++++++++++++++---------
lib/ts/Diags.cc | 7 +-
lib/ts/runroot.cc | 21 +++--
lib/tsconfig/Errata.cc | 6 +-
mgmt/api/NetworkMessage.cc | 3 +-
plugins/experimental/tls_bridge/regex.cc | 12 ++-
plugins/experimental/tls_bridge/tls_bridge.cc | 23 +++--
plugins/experimental/url_sig/url_sig.c | 3 +-
plugins/header_rewrite/conditions.cc | 3 +-
proxy/InkAPI.cc | 5 +-
proxy/InkAPITest.cc | 3 +-
proxy/Main.cc | 5 +-
proxy/http/HttpConnectionCount.cc | 3 +-
proxy/http/HttpTransact.cc | 3 +-
proxy/http/HttpTransactHeaders.cc | 3 +-
proxy/http/remap/RemapProcessor.cc | 3 +-
proxy/logging/LogObject.cc | 3 +-
33 files changed, 238 insertions(+), 131 deletions(-)
diff --git a/cmd/traffic_layout/engine.cc b/cmd/traffic_layout/engine.cc
index d9765a8..ab8710b 100644
--- a/cmd/traffic_layout/engine.cc
+++ b/cmd/traffic_layout/engine.cc
@@ -54,10 +54,12 @@ check_force()
std::cout << "Are you sure to overwrite and force creating/removing runroot? (irreversible) Y/N: ";
std::string input;
std::cin >> input;
- if (input == "Y" || input == "y")
+ if (input == "Y" || input == "y") {
return true;
- if (input == "N" || input == "n")
+ }
+ if (input == "N" || input == "n") {
return false;
+ }
}
ink_error("Invalid input Y/N");
exit(70);
@@ -539,8 +541,9 @@ RunrootEngine::verify_runroot()
std::string name = it.first;
std::string value = it.second;
- if (name == "prefix" || name == "exec_prefix")
+ if (name == "prefix" || name == "exec_prefix") {
continue;
+ }
permission_map[name] = "000"; // default rwx all 0
diff --git a/cmd/traffic_layout/file_system.cc b/cmd/traffic_layout/file_system.cc
index dbccb5a..94e894c 100644
--- a/cmd/traffic_layout/file_system.cc
+++ b/cmd/traffic_layout/file_system.cc
@@ -44,15 +44,17 @@ static std::string remove_path;
void
append_slash(std::string &path)
{
- if (path.back() != '/')
+ if (path.back() != '/') {
path.append("/");
+ }
}
void
remove_slash(std::string &path)
{
- if (path.back() == '/')
+ if (path.back() == '/') {
path.pop_back();
+ }
}
bool
@@ -92,15 +94,17 @@ create_directory(const std::string &dir)
// create directory one layer by one layer
while (1) {
pos = s.find("/", pos1);
- if ((size_t)pos == s.npos)
+ if ((size_t)pos == s.npos) {
break;
+ }
ret = mkdir(s.substr(0, pos).c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
pos1 = pos + 1;
}
- if (ret)
+ if (ret) {
return false;
- else
+ } else {
return true;
+ }
}
static int
@@ -150,10 +154,11 @@ remove_directory(const std::string &dir)
{
std::string path = dir;
remove_slash(path);
- if (nftw(path.c_str(), remove_function, OPEN_MAX_FILE, FTW_DEPTH))
+ if (nftw(path.c_str(), remove_function, OPEN_MAX_FILE, FTW_DEPTH)) {
return false;
- else
+ } else {
return true;
+ }
}
// remove everything inside this directory
@@ -163,10 +168,11 @@ remove_inside_directory(const std::string &dir)
std::string path = dir;
remove_slash(path);
remove_path = path;
- if (nftw(path.c_str(), remove_inside_function, OPEN_MAX_FILE, FTW_DEPTH))
+ if (nftw(path.c_str(), remove_inside_function, OPEN_MAX_FILE, FTW_DEPTH)) {
return false;
- else
+ } else {
return true;
+ }
}
static int
@@ -175,8 +181,9 @@ copy_function(const char *src_path, const struct stat *sb, int flag)
// src path no slash
std::string full_src_path = src_path;
if (full_src_path == src_root) {
- if (!create_directory(dst_root))
+ if (!create_directory(dst_root)) {
ink_fatal("create directory failed during copy");
+ }
return 0;
}
std::string src_back = full_src_path.substr(src_root.size() + 1);
@@ -185,8 +192,9 @@ copy_function(const char *src_path, const struct stat *sb, int flag)
switch (flag) {
case FTW_D:
// create directory for FTW_D type
- if (!create_directory(dst_path))
+ if (!create_directory(dst_path)) {
ink_fatal("create directory failed during copy");
+ }
break;
case FTW_F:
// if the file already exist, overwrite it
@@ -198,8 +206,9 @@ copy_function(const char *src_path, const struct stat *sb, int flag)
// hardlink bin executable
if (sb->st_mode == BIN_MODE) {
if (link(src_path, dst_path.c_str()) != 0) {
- if (errno != EEXIST)
+ if (errno != EEXIST) {
ink_warning("failed to create hard link - %s", strerror(errno));
+ }
}
} else {
// for normal other files
@@ -223,8 +232,9 @@ copy_directory(const std::string &src, const std::string &dst)
remove_slash(src_root);
append_slash(dst_root);
- if (ftw(src_root.c_str(), copy_function, OPEN_MAX_FILE))
+ if (ftw(src_root.c_str(), copy_function, OPEN_MAX_FILE)) {
return false;
- else
+ } else {
return true;
+ }
}
diff --git a/cmd/traffic_layout/info.cc b/cmd/traffic_layout/info.cc
index 94528b1..0a47699 100644
--- a/cmd/traffic_layout/info.cc
+++ b/cmd/traffic_layout/info.cc
@@ -116,11 +116,12 @@ produce_features(bool json)
void
print_var(ts::string_view const &name, ts::string_view const &value, bool json, bool last = false)
{
- if (json)
+ if (json) {
printf(R"( "%.*s": "%.*s"%s)", static_cast<int>(name.size()), name.data(), static_cast<int>(value.size()), value.data(),
last ? "\n" : ",\n");
- else
+ } else {
printf("%.*s: %.*s\n", static_cast<int>(name.size()), name.data(), static_cast<int>(value.size()), value.data());
+ }
}
void
diff --git a/cmd/traffic_layout/traffic_layout.cc b/cmd/traffic_layout/traffic_layout.cc
index 40dab37..8893fd4 100644
--- a/cmd/traffic_layout/traffic_layout.cc
+++ b/cmd/traffic_layout/traffic_layout.cc
@@ -164,8 +164,9 @@ main(int argc, const char **argv)
// with command (info, init, remove)
for (unsigned i = 0; i < countof(commands); ++i) {
- if (!argv[1])
+ if (!argv[1]) {
break;
+ }
if (strcmp(argv[1], commands[i].name.c_str()) == 0) {
return commands[i].handler(argc, argv);
}
diff --git a/iocore/dns/DNSConnection.cc b/iocore/dns/DNSConnection.cc
index c13d0f0..7a289d6 100644
--- a/iocore/dns/DNSConnection.cc
+++ b/iocore/dns/DNSConnection.cc
@@ -183,8 +183,9 @@ DNSConnection::connect(sockaddr const *addr, Options const &opt)
#endif
#ifdef SET_SO_KEEPALIVE
// enables 2 hour inactivity probes, also may fix IRIX FIN_WAIT_2 leak
- if ((res = safe_setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, SOCKOPT_ON, sizeof(int))) < 0)
+ if ((res = safe_setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, SOCKOPT_ON, sizeof(int))) < 0) {
goto Lerror;
+ }
#endif
ats_ip_copy(&ip.sa, addr);
diff --git a/iocore/eventsystem/UnixEThread.cc b/iocore/eventsystem/UnixEThread.cc
index 7fbede5..f2d04de 100644
--- a/iocore/eventsystem/UnixEThread.cc
+++ b/iocore/eventsystem/UnixEThread.cc
@@ -236,9 +236,9 @@ EThread::execute_regular()
while ((e = EventQueue.dequeue_ready(cur_time))) {
ink_assert(e);
ink_assert(e->timeout_at > 0);
- if (e->cancelled)
+ if (e->cancelled) {
free_event(e);
- else {
+ } else {
done_one = true;
process_event(e, e->callback_event);
}
@@ -360,11 +360,13 @@ EThread::summarize_stats(EventMetrics summary[N_EVENT_TIMESCALES])
for (int t = 0; t < N_EVENT_TIMESCALES; ++t) {
int count = SAMPLE_COUNT[t];
- if (t > 0)
+ if (t > 0) {
count -= SAMPLE_COUNT[t - 1];
+ }
while (--count >= 0) {
- if (0 != m->_loop_time._start)
+ if (0 != m->_loop_time._start) {
sum += *m;
+ }
m = this->prev(m);
}
summary[t] += sum; // push out to return vector.
diff --git a/iocore/hostdb/HostDB.cc b/iocore/hostdb/HostDB.cc
index 081afa1..184d3eb 100644
--- a/iocore/hostdb/HostDB.cc
+++ b/iocore/hostdb/HostDB.cc
@@ -2330,8 +2330,9 @@ ParseHostFile(const char *path, unsigned int hostdb_hostfile_check_interval)
}
// Swap the pointer
- if (parsed_hosts_file_ptr != nullptr)
+ if (parsed_hosts_file_ptr != nullptr) {
hostDB.hosts_file_ptr = parsed_hosts_file_ptr;
+ }
// Mark this one as completed, so we can allow another update to happen
HostDBFileUpdateActive = 0;
}
diff --git a/iocore/net/SNIActionPerformer.cc b/iocore/net/SNIActionPerformer.cc
index b14e9c9..710a7b5 100644
--- a/iocore/net/SNIActionPerformer.cc
+++ b/iocore/net/SNIActionPerformer.cc
@@ -42,12 +42,13 @@ SNIActionPerformer::PerformAction(Continuation *cont, cchar *servername)
{
SNIConfig::scoped_config params;
auto actionvec = params->get(servername);
- if (!actionvec)
+ if (!actionvec) {
Debug("ssl_sni", "%s not available in the map", servername);
- else {
+ } else {
for (auto it : *actionvec) {
- if (it)
+ if (it) {
it->SNIAction(cont);
+ }
}
}
}
diff --git a/iocore/net/SSLClientUtils.cc b/iocore/net/SSLClientUtils.cc
index 0f0f60c..367f634 100644
--- a/iocore/net/SSLClientUtils.cc
+++ b/iocore/net/SSLClientUtils.cc
@@ -58,10 +58,10 @@ verify_callback(int preverify_ok, X509_STORE_CTX *ctx)
// Don't bother to check the hostname if we failed openssl's verification
SSLDebug("verify error:num=%d:%s:depth=%d", err, X509_verify_cert_error_string(err), depth);
if (netvc && netvc->options.clientVerificationFlag == 2) {
- if (netvc->options.sni_servername)
+ if (netvc->options.sni_servername) {
Warning("Hostname verification failed for (%s) but still continuing with the connection establishment",
netvc->options.sni_servername.get());
- else {
+ } else {
char buff[INET6_ADDRSTRLEN];
ats_ip_ntop(netvc->get_remote_addr(), buff, INET6_ADDRSTRLEN);
Warning("Server certificate verification failed for %s but still continuing with the connection establishment", buff);
diff --git a/iocore/net/SSLConfig.cc b/iocore/net/SSLConfig.cc
index a6ad219..eebaf8a 100644
--- a/iocore/net/SSLConfig.cc
+++ b/iocore/net/SSLConfig.cc
@@ -395,8 +395,9 @@ SSLConfigParams::printCTXmap() const
{
Vec<cchar *> keys;
ctx_map.get_keys(keys);
- for (size_t i = 0; i < keys.length(); i++)
+ for (size_t i = 0; i < keys.length(); i++) {
Debug("ssl", "Client certificates in the map %s: %p", keys.get(i), ctx_map.get(keys.get(i)));
+ }
}
void
SSLConfigParams::freeCTXmap() const
diff --git a/iocore/net/SSLNetVConnection.cc b/iocore/net/SSLNetVConnection.cc
index 7e1b169..4315a6b 100644
--- a/iocore/net/SSLNetVConnection.cc
+++ b/iocore/net/SSLNetVConnection.cc
@@ -362,8 +362,9 @@ SSLNetVConnection::read_raw_data()
total_read += rattempted;
// last read failed or was incomplete
- if (r != rattempted || !b)
+ if (r != rattempted || !b) {
break;
+ }
rattempted = b->write_avail();
}
diff --git a/iocore/net/SSLSNIConfig.cc b/iocore/net/SSLSNIConfig.cc
index 8f14d5b..eaacf79 100644
--- a/iocore/net/SSLSNIConfig.cc
+++ b/iocore/net/SSLSNIConfig.cc
@@ -53,8 +53,9 @@ SNIConfigParams::getPropertyConfig(cchar *servername) const
{
NextHopProperty *nps = nullptr;
nps = next_hop_table.get(servername);
- if (!nps)
+ if (!nps) {
nps = wild_next_hop_table.get(servername);
+ }
return nps;
}
@@ -76,8 +77,9 @@ SNIConfigParams::loadSNIConfig()
if (wildcard) {
ts::TextView domain{servername, strlen(servername)};
domain.take_prefix_at('.');
- if (!domain.empty())
+ if (!domain.empty()) {
wild_sni_action_map.put(ats_stringdup(domain), aiVec);
+ }
} else {
sni_action_map.put(ats_strdup(servername), aiVec);
}
@@ -98,10 +100,11 @@ SNIConfigParams::loadSNIConfig()
nps->name = ats_strdup(servername);
nps->verifyLevel = item.verify_origin_server;
nps->ctx = clientCTX;
- if (wildcard)
+ if (wildcard) {
wild_next_hop_table.put(nps->name, nps);
- else
+ } else {
next_hop_table.put(nps->name, nps);
+ }
} // end for
}
@@ -176,8 +179,9 @@ SNIConfigParams::cleanup()
sni_action_map.get_keys(keys);
for (int i = keys.length() - 1; i >= 0; i--) {
auto actionVec = sni_action_map.get(keys.get(i));
- for (auto &ai : *actionVec)
+ for (auto &ai : *actionVec) {
delete ai;
+ }
actionVec->clear();
}
@@ -186,8 +190,9 @@ SNIConfigParams::cleanup()
wild_sni_action_map.get_keys(keys);
for (int i = keys.length() - 1; i >= 0; i--) {
auto actionVec = wild_sni_action_map.get(keys.get(i));
- for (auto &ai : *actionVec)
+ for (auto &ai : *actionVec) {
delete ai;
+ }
actionVec->clear();
}
diff --git a/iocore/net/SSLSessionCache.cc b/iocore/net/SSLSessionCache.cc
index ba12185..0223258 100644
--- a/iocore/net/SSLSessionCache.cc
+++ b/iocore/net/SSLSessionCache.cc
@@ -177,8 +177,9 @@ SSLSessionBucket::getSessionBuffer(const SSLSessionID &id, char *buffer, int &le
if (ssl_rsb) {
SSL_INCREMENT_DYN_STAT(ssl_session_cache_lock_contention);
}
- if (SSLConfigParams::session_cache_skip_on_lock_contention)
+ if (SSLConfigParams::session_cache_skip_on_lock_contention) {
return true_len;
+ }
lock.acquire(this_ethread());
}
@@ -190,8 +191,9 @@ SSLSessionBucket::getSessionBuffer(const SSLSessionID &id, char *buffer, int &le
true_len = node->len_asn1_data;
if (buffer) {
const unsigned char *loc = reinterpret_cast<const unsigned char *>(node->asn1_data->data());
- if (true_len < len)
+ if (true_len < len) {
len = true_len;
+ }
memcpy(buffer, loc, len);
return true_len;
}
diff --git a/iocore/net/SSLUtils.cc b/iocore/net/SSLUtils.cc
index 4921d72..5951c76 100644
--- a/iocore/net/SSLUtils.cc
+++ b/iocore/net/SSLUtils.cc
@@ -1851,12 +1851,14 @@ SSLInitServerContext(const SSLConfigParams *params, const ssl_user_config *sslMu
return ctx;
fail:
- if (digest)
+ if (digest) {
EVP_MD_CTX_free(digest);
+ }
SSL_CLEAR_PW_REFERENCES(ctx)
SSLReleaseContext(ctx);
- for (auto cert : certList)
+ for (auto cert : certList) {
X509_free(cert);
+ }
return nullptr;
}
diff --git a/iocore/net/UnixNet.cc b/iocore/net/UnixNet.cc
index 880f490..f2930db 100644
--- a/iocore/net/UnixNet.cc
+++ b/iocore/net/UnixNet.cc
@@ -280,14 +280,16 @@ NetHandler::update_nethandler_config(const char *str, RecDataT, RecData data, vo
void *idx = reinterpret_cast<void *>(static_cast<intptr_t>(updated_member - &global_config[0]));
// Signal the NetHandler instances, passing the index of the updated config value.
for (int i = 0; i < eventProcessor.n_thread_groups; ++i) {
- if (!active_thread_types[i])
+ if (!active_thread_types[i]) {
continue;
+ }
for (EThread **tp = eventProcessor.thread_group[i]._thread,
**limit = eventProcessor.thread_group[i]._thread + eventProcessor.thread_group[i]._count;
tp < limit; ++tp) {
NetHandler *nh = get_NetHandler(*tp);
- if (nh)
+ if (nh) {
nh->thread->schedule_imm(nh, TS_EVENT_MGMT_UPDATE, idx);
+ }
}
}
}
@@ -385,11 +387,11 @@ NetHandler::process_ready_list()
while ((vc = read_ready_list.dequeue())) {
// Initialize the thread-local continuation flags
set_cont_flags(vc->control_flags);
- if (vc->closed)
+ if (vc->closed) {
free_netvc(vc);
- else if (vc->read.enabled && vc->read.triggered)
+ } else if (vc->read.enabled && vc->read.triggered) {
vc->net_read_io(this, this->thread);
- else if (!vc->read.enabled) {
+ } else if (!vc->read.enabled) {
read_ready_list.remove(vc);
#if defined(solaris)
if (vc->read.triggered && vc->write.enabled) {
@@ -402,11 +404,11 @@ NetHandler::process_ready_list()
}
while ((vc = write_ready_list.dequeue())) {
set_cont_flags(vc->control_flags);
- if (vc->closed)
+ if (vc->closed) {
free_netvc(vc);
- else if (vc->write.enabled && vc->write.triggered)
+ } else if (vc->write.enabled && vc->write.triggered) {
write_to_net(this, vc, this->thread);
- else if (!vc->write.enabled) {
+ } else if (!vc->write.enabled) {
write_ready_list.remove(vc);
#if defined(solaris)
if (vc->write.triggered && vc->read.enabled) {
@@ -448,8 +450,9 @@ NetHandler::mainNetEvent(int event, Event *e)
intptr_t idx = reinterpret_cast<intptr_t>(e->cookie);
// Copy to the same offset in the instance struct.
config[idx] = global_config[idx];
- if (config_value_affects_per_thread_value[idx])
+ if (config_value_affects_per_thread_value[idx]) {
this->configure_per_thread_values();
+ }
return EVENT_CONT;
} else {
ink_assert(trigger_event == e && (event == EVENT_INTERVAL || event == EVENT_POLL));
diff --git a/iocore/net/UnixNetProcessor.cc b/iocore/net/UnixNetProcessor.cc
index 92c37c0..beec36d 100644
--- a/iocore/net/UnixNetProcessor.cc
+++ b/iocore/net/UnixNetProcessor.cc
@@ -428,8 +428,9 @@ UnixNetProcessor::init()
netHandler_offset = eventProcessor.allocate(sizeof(NetHandler));
pollCont_offset = eventProcessor.allocate(sizeof(PollCont));
- if (0 == accept_mss)
+ if (0 == accept_mss) {
REC_ReadConfigInteger(accept_mss, "proxy.config.net.sock_mss_in");
+ }
// NetHandler - do the global configuration initialization and then
// schedule per thread start up logic. Global init is done only here.
diff --git a/lib/ts/BufferWriterFormat.cc b/lib/ts/BufferWriterFormat.cc
index b5ac0b3..80d5e16 100644
--- a/lib/ts/BufferWriterFormat.cc
+++ b/lib/ts/BufferWriterFormat.cc
@@ -71,8 +71,9 @@ BWFSpec::BWFSpec(TextView fmt)
_name = fmt.take_prefix_at(':');
// if it's parsable as a number, treat it as an index.
n = tv_to_positive_decimal(_name, &num);
- if (num.size())
+ if (num.size()) {
_idx = static_cast<decltype(_idx)>(n);
+ }
if (fmt.size()) {
TextView sz = fmt.take_prefix_at(':'); // the format specifier.
@@ -99,33 +100,38 @@ BWFSpec::BWFSpec(TextView fmt)
} else if (Align::NONE != (_align = align_of(*sz))) {
++sz;
}
- if (!sz.size())
+ if (!sz.size()) {
return;
+ }
// sign
if (is_sign(*sz)) {
_sign = *sz;
- if (!(++sz).size())
+ if (!(++sz).size()) {
return;
+ }
}
// radix prefix
if ('#' == *sz) {
_radix_lead_p = true;
- if (!(++sz).size())
+ if (!(++sz).size()) {
return;
+ }
}
// 0 fill for integers
if ('0' == *sz) {
- if (Align::NONE == _align)
+ if (Align::NONE == _align) {
_align = Align::SIGN;
- _fill = '0';
+ }
+ _fill = '0';
++sz;
}
n = tv_to_positive_decimal(sz, &num);
if (num.size()) {
_min = static_cast<decltype(_min)>(n);
sz.remove_prefix(num.size());
- if (!sz.size())
+ if (!sz.size()) {
return;
+ }
}
// precision
if ('.' == *sz) {
@@ -133,8 +139,9 @@ BWFSpec::BWFSpec(TextView fmt)
if (num.size()) {
_prec = static_cast<decltype(_prec)>(n);
sz.remove_prefix(num.size());
- if (!sz.size())
+ if (!sz.size()) {
return;
+ }
} else {
throw std::invalid_argument("Precision mark without precision");
}
@@ -142,8 +149,9 @@ BWFSpec::BWFSpec(TextView fmt)
// style (type). Hex, octal, etc.
if (is_type(*sz)) {
_type = *sz;
- if (!(++sz).size())
+ if (!(++sz).size()) {
return;
+ }
}
// maximum width
if (',' == *sz) {
@@ -151,16 +159,18 @@ BWFSpec::BWFSpec(TextView fmt)
if (num.size()) {
_max = static_cast<decltype(_max)>(n);
sz.remove_prefix(num.size());
- if (!sz.size())
+ if (!sz.size()) {
return;
+ }
} else {
throw std::invalid_argument("Maximum width mark without width");
}
// Can only have a type indicator here if there was a max width.
if (is_type(*sz)) {
_type = *sz;
- if (!(++sz).size())
+ if (!(++sz).size()) {
return;
+ }
}
}
}
@@ -202,16 +212,19 @@ namespace bw_fmt
dst = base + delta; // move existing content to here.
if (dst < limit) {
last = dst + size; // amount of data to move.
- if (last > limit)
+ if (last > limit) {
last = limit;
+ }
std::memmove(dst, base, last - dst);
}
dst = base;
last = base + delta;
- if (last > limit)
+ if (last > limit) {
last = limit;
- while (dst < last)
+ }
+ while (dst < last) {
*dst++ = spec._fill;
+ }
break;
case BWFSpec::Align::CENTER:
d2 = (delta + 1) / 2;
@@ -219,40 +232,48 @@ namespace bw_fmt
dst = base + d2; // move existing content to here.
if (dst < limit) {
last = dst + size; // amount of data to move.
- if (last > limit)
+ if (last > limit) {
last = limit;
+ }
std::memmove(dst, base, last - dst);
}
dst = base + size + d2;
last = base + delta / 2;
- if (last > limit)
+ if (last > limit) {
last = limit;
- while (dst < last)
+ }
+ while (dst < last) {
*dst++ = spec._fill;
+ }
}
dst = base;
last = base + d2;
- if (last > limit)
+ if (last > limit) {
last = limit;
- while (dst < last)
+ }
+ while (dst < last) {
*dst++ = spec._fill;
+ }
break;
default:
// Everything else is equivalent to LEFT - distinction is for more specialized
// types such as integers.
dst = base + size;
last = dst + delta;
- if (last > limit)
+ if (last > limit) {
last = limit;
- while (dst < last)
+ }
+ while (dst < last) {
*dst++ = spec._fill;
+ }
break;
}
w.fill(min);
} else {
size_t max = spec._max;
- if (max < extent)
+ if (max < extent) {
extent = max;
+ }
w.fill(extent);
}
}
@@ -294,38 +315,48 @@ namespace bw_fmt
{
switch (align) {
case BWFSpec::Align::LEFT:
- if (neg)
+ if (neg) {
w.write(neg);
+ }
f();
- while (width-- > 0)
+ while (width-- > 0) {
w.write(fill);
+ }
break;
case BWFSpec::Align::RIGHT:
- while (width-- > 0)
+ while (width-- > 0) {
w.write(fill);
- if (neg)
+ }
+ if (neg) {
w.write(neg);
+ }
f();
break;
case BWFSpec::Align::CENTER:
- for (int i = width / 2; i > 0; --i)
+ for (int i = width / 2; i > 0; --i) {
w.write(fill);
- if (neg)
+ }
+ if (neg) {
w.write(neg);
+ }
f();
- for (int i = (width + 1) / 2; i > 0; --i)
+ for (int i = (width + 1) / 2; i > 0; --i) {
w.write(fill);
+ }
break;
case BWFSpec::Align::SIGN:
- if (neg)
+ if (neg) {
w.write(neg);
- while (width-- > 0)
+ }
+ while (width-- > 0) {
w.write(fill);
+ }
f();
break;
default:
- if (neg)
+ if (neg) {
w.write(neg);
+ }
f();
break;
}
@@ -373,34 +404,40 @@ namespace bw_fmt
break;
}
// Clip fill width by stuff that's already committed to be written.
- if (neg)
+ if (neg) {
--width;
+ }
if (prefix1) {
--width;
- if (prefix2)
+ if (prefix2) {
--width;
+ }
}
width -= static_cast<int>(n);
string_view digits{buff + sizeof(buff) - n, n};
if (spec._align == BWFSpec::Align::SIGN) { // custom for signed case because prefix and digits are seperated.
- if (neg)
+ if (neg) {
w.write(neg);
+ }
if (prefix1) {
w.write(prefix1);
- if (prefix2)
+ if (prefix2) {
w.write(prefix2);
+ }
}
- while (width-- > 0)
+ while (width-- > 0) {
w.write(spec._fill);
+ }
w.write(digits);
} else { // use generic Write_Aligned
Write_Aligned(w,
[&]() {
if (prefix1) {
w.write(prefix1);
- if (prefix2)
+ if (prefix2) {
w.write(prefix2);
+ }
}
w.write(digits);
},
@@ -491,8 +528,9 @@ namespace bw_fmt
r = bw_fmt::To_Radix<10>(frac_part, fraction, sizeof(fraction), bw_fmt::LOWER_DIGITS);
// Clip fill width
- if (neg)
+ if (neg) {
--width;
+ }
width -= static_cast<int>(l);
--width; // '.'
width -= static_cast<int>(r);
@@ -529,8 +567,9 @@ BufferWriter &
bwformat(BufferWriter &w, BWFSpec const &spec, string_view sv)
{
int width = static_cast<int>(spec._min); // amount left to fill.
- if (spec._prec > 0)
+ if (spec._prec > 0) {
sv.remove_prefix(spec._prec);
+ }
if ('x' == spec._type || 'X' == spec._type) {
const char *digits = 'x' == spec._type ? bw_fmt::LOWER_DIGITS : bw_fmt::UPPER_DIGITS;
@@ -651,8 +690,9 @@ bw_fmt::Global_Table_Find(string_view name)
{
if (name.size()) {
auto spot = bw_fmt::BWF_GLOBAL_TABLE.find(name);
- if (spot != bw_fmt::BWF_GLOBAL_TABLE.end())
+ if (spot != bw_fmt::BWF_GLOBAL_TABLE.end()) {
return spot->second;
+ }
}
return nullptr;
}
diff --git a/lib/ts/Diags.cc b/lib/ts/Diags.cc
index 9ecc8ff..005e2f5 100644
--- a/lib/ts/Diags.cc
+++ b/lib/ts/Diags.cc
@@ -818,8 +818,9 @@ Diags::set_std_output(StdStream stream, const char *file)
unlock();
// Free the BaseLogFile we rotated out
- if (old_log)
+ if (old_log) {
delete old_log;
+ }
// "this should never happen"^{TM}
ink_release_assert(ret);
@@ -848,9 +849,9 @@ Diags::rebind_std_stream(StdStream stream, int new_fd)
}
(void)target_stream; // silence clang-analyzer for now
- if (new_fd < 0)
+ if (new_fd < 0) {
log_log_error("[Warning]: TS unable to bind %s to new file descriptor=%d", target_stream, new_fd);
- else {
+ } else {
dup2(new_fd, stream_fd);
return true;
}
diff --git a/lib/ts/runroot.cc b/lib/ts/runroot.cc
index bf05f48..d538e34 100644
--- a/lib/ts/runroot.cc
+++ b/lib/ts/runroot.cc
@@ -69,8 +69,9 @@ std::string
check_parent_path(const std::string &path)
{
std::string whole_path = path;
- if (whole_path.back() == '/')
+ if (whole_path.back() == '/') {
whole_path.pop_back();
+ }
// go up to 4 level of parent directories
for (int i = 0; i < 4; i++) {
@@ -121,13 +122,15 @@ runroot_handler(const char **argv, bool json)
prefix += "=";
path = check_path(arg.substr(prefix.size(), arg.size() - 1));
if (!path.empty()) {
- if (!json)
+ if (!json) {
ink_notice("using command line path as RUNROOT");
+ }
using_runroot = path;
return;
} else {
- if (!json)
+ if (!json) {
ink_warning("bad RUNROOT passed in");
+ }
}
}
@@ -137,12 +140,14 @@ runroot_handler(const char **argv, bool json)
path = check_path(env_val);
if (!path.empty()) {
using_runroot = env_val;
- if (!json)
+ if (!json) {
ink_notice("using the environment variable TS_RUNROOT");
+ }
return;
} else {
- if (!json)
+ if (!json) {
ink_warning("bad Environment var: $TS_RUNROOT");
+ }
}
}
@@ -152,8 +157,9 @@ runroot_handler(const char **argv, bool json)
path = check_parent_path(cwd);
if (!path.empty()) {
using_runroot = path;
- if (!json)
+ if (!json) {
ink_notice("using cwd as TS_RUNROOT");
+ }
return;
}
}
@@ -166,8 +172,9 @@ runroot_handler(const char **argv, bool json)
path = check_parent_path(bindir);
if (!path.empty()) {
using_runroot = path;
- if (!json)
+ if (!json) {
ink_notice("using the installed dir as TS_RUNROOT");
+ }
return;
}
}
diff --git a/lib/tsconfig/Errata.cc b/lib/tsconfig/Errata.cc
index 0d1c5e9..14ab513 100644
--- a/lib/tsconfig/Errata.cc
+++ b/lib/tsconfig/Errata.cc
@@ -70,7 +70,8 @@ inline Errata::Errata(ImpPtr const& ptr)
Errata::Data::~Data() {
if (m_log_on_delete) {
Errata tmp(this); // because client API requires a wrapper.
- for ( auto& f : Sink_List ) (*f)(tmp);
+ for ( auto& f : Sink_List ) { (*f)(tmp);
+}
tmp.m_data.release(); // don't delete this again.
}
}
@@ -239,8 +240,9 @@ Errata::write(
out << m.m_id << " [" << m.m_code << "]: " << m.m_text
<< std::endl
;
- if (m.getErrata().size())
+ if (m.getErrata().size()) {
m.getErrata().write(out, offset, indent+shift, shift, lead);
+}
}
return out;
diff --git a/mgmt/api/NetworkMessage.cc b/mgmt/api/NetworkMessage.cc
index 6d2cb54..b786696 100644
--- a/mgmt/api/NetworkMessage.cc
+++ b/mgmt/api/NetworkMessage.cc
@@ -121,8 +121,9 @@ send_mgmt_request(const mgmt_message_sender &snd, OpType optype, ...)
const MgmtMarshallType lenfield[] = {MGMT_MARSHALL_INT};
const NetCmdOperation *cmd;
- if (!snd.is_connected())
+ if (!snd.is_connected()) {
return TS_ERR_NET_ESTABLISH; // no connection.
+ }
GETCMD(requests, optype, cmd);
diff --git a/plugins/experimental/tls_bridge/regex.cc b/plugins/experimental/tls_bridge/regex.cc
index 3e47c40..2a4558f 100644
--- a/plugins/experimental/tls_bridge/regex.cc
+++ b/plugins/experimental/tls_bridge/regex.cc
@@ -55,8 +55,9 @@ Regex::compile(const char *pattern, const unsigned flags)
int options = 0;
int study_opts = 0;
- if (regex)
+ if (regex) {
return false;
+ }
if (flags & CASE_INSENSITIVE) {
options |= PCRE_CASELESS;
@@ -79,8 +80,9 @@ Regex::compile(const char *pattern, const unsigned flags)
regex_extra = pcre_study(regex, study_opts, &error);
#ifdef PCRE_CONFIG_JIT
- if (regex_extra)
+ if (regex_extra) {
pcre_assign_jit_stack(regex_extra, &get_jit_stack, nullptr);
+ }
#endif
return true;
@@ -115,12 +117,14 @@ Regex::exec(ts::string_view src, int *ovector, int ovecsize) const
Regex::~Regex()
{
- if (regex_extra)
+ if (regex_extra) {
#ifdef PCRE_CONFIG_JIT
pcre_free_study(regex_extra);
+ }
#else
pcre_free(regex_extra);
#endif
- if (regex)
+ if (regex) {
pcre_free(regex);
+ }
}
diff --git a/plugins/experimental/tls_bridge/tls_bridge.cc b/plugins/experimental/tls_bridge/tls_bridge.cc
index 04724f6..1577f92 100644
--- a/plugins/experimental/tls_bridge/tls_bridge.cc
+++ b/plugins/experimental/tls_bridge/tls_bridge.cc
@@ -262,12 +262,14 @@ Bridge::read_ready(TSVIO vio)
case EOS:
break;
case OPEN:
- if (!this->check_outbound_OK() || _out_resp_state != OK)
+ if (!this->check_outbound_OK() || _out_resp_state != OK) {
break;
+ }
// FALL THROUGH
case OK:
- if (!this->check_outbound_terminal() || _out_resp_state != READY)
+ if (!this->check_outbound_terminal() || _out_resp_state != READY) {
break;
+ }
// FALL THROUGH
case READY:
// Do setup for flowing upstream data to user agent.
@@ -342,10 +344,11 @@ Bridge::check_outbound_terminal()
while (block) {
char c = *block;
if ('\r' == c) {
- if (_out_terminal_pos == 2)
+ if (_out_terminal_pos == 2) {
_out_terminal_pos = 3;
- else
+ } else {
_out_terminal_pos = 1;
+ }
} else if ('\n' == c) {
if (_out_terminal_pos == 3) {
_out_terminal_pos = 4;
@@ -413,8 +416,9 @@ Bridge::eos(TSVIO vio)
_out.do_close();
_ua.do_close();
_out_resp_state = EOS;
- if (_ua_response_suspended)
+ if (_ua_response_suspended) {
TSHttpTxnReenable(_ua_txn, TS_EVENT_HTTP_CONTINUE);
+ }
}
void
@@ -444,8 +448,9 @@ Bridge::update_ua_response()
TSHttpStatus status = TSHttpHdrStatusGet(mbuf, hdr_loc);
if (TS_HTTP_STATUS_OK == status && TS_HTTP_STATUS_OK != _out_response_code) {
TSHttpHdrStatusSet(mbuf, hdr_loc, _out_response_code);
- if (!_out_response_reason.empty())
+ if (!_out_response_reason.empty()) {
TSHttpHdrReasonSet(mbuf, hdr_loc, _out_response_reason.data(), _out_response_reason.size());
+ }
}
// TS insists on adding these fields, despite it being a CONNECT.
Hdr_Remove_Field(mbuf, hdr_loc, {TS_MIME_FIELD_TRANSFER_ENCODING, TS_MIME_LEN_TRANSFER_ENCODING});
@@ -618,12 +623,14 @@ TSPluginInit(int argc, char const *argv[])
{
TSPluginRegistrationInfo info{PLUGIN_NAME, "Oath:", "solidwallofcode@oath.com"};
- if (TSPluginRegister(&info) != TS_SUCCESS)
+ if (TSPluginRegister(&info) != TS_SUCCESS) {
TSError(PLUGIN_NAME ": plugin registration failed.");
+ }
Config.load_config(argc - 1, argv + 1);
- if (Config.count() <= 0)
+ if (Config.count() <= 0) {
TSError("%s: No destinations defined, plugin disabled", PLUGIN_TAG);
+ }
TSCont contp = TSContCreate(CB_Read_Request_Hdr, TSMutexCreate());
TSHttpHookAdd(TS_HTTP_READ_REQUEST_HDR_HOOK, contp);
diff --git a/plugins/experimental/url_sig/url_sig.c b/plugins/experimental/url_sig/url_sig.c
index b0400a3..299d279 100644
--- a/plugins/experimental/url_sig/url_sig.c
+++ b/plugins/experimental/url_sig/url_sig.c
@@ -514,8 +514,9 @@ TSRemapDoRemap(void *ih, TSHttpTxn txnp, TSRemapRequestInfo *rri)
/* Only search up to the first ? or # */
const char *base_url_end = url;
- while (*base_url_end && !(*base_url_end == '?' || *base_url_end == '#'))
+ while (*base_url_end && !(*base_url_end == '?' || *base_url_end == '#')) {
++base_url_end;
+ }
const int len = base_url_end - url;
if (pcre_exec(cfg->regex, cfg->regex_extra, url, len, offset, options, ovector, 30) >= 0) {
diff --git a/plugins/header_rewrite/conditions.cc b/plugins/header_rewrite/conditions.cc
index 75fec11..5691e1a 100644
--- a/plugins/header_rewrite/conditions.cc
+++ b/plugins/header_rewrite/conditions.cc
@@ -1393,8 +1393,9 @@ ConditionInbound::append_value(std::string &s, const Resources &res, NetworkSess
}
s.reserve(len);
for (int i = 0; i < count; ++i) {
- if (i)
+ if (i) {
s += ',';
+ }
s += tags[i];
}
} break;
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 61f77e1..cc830aa 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -5936,9 +5936,10 @@ TSHttpArgIndexReserve(UserArg::Type type, const char *name, const char *descript
if (idx < limit) {
UserArg &arg(UserArgTable[type][idx]);
arg.name = name;
- if (description)
+ if (description) {
arg.description = description;
- *ptr_idx = idx;
+ }
+ *ptr_idx = idx;
return TS_SUCCESS;
}
diff --git a/proxy/InkAPITest.cc b/proxy/InkAPITest.cc
index 00b79b9..2085ebd 100644
--- a/proxy/InkAPITest.cc
+++ b/proxy/InkAPITest.cc
@@ -6540,8 +6540,9 @@ struct AppendTransformTestData {
~AppendTransformTestData()
{
- if (output_buffer)
+ if (output_buffer) {
TSIOBufferDestroy(output_buffer);
+ }
}
};
diff --git a/proxy/Main.cc b/proxy/Main.cc
index 0034f05..a9ebee7 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -445,10 +445,11 @@ private:
void
set_debug_ip(const char *ip_string)
{
- if (ip_string)
+ if (ip_string) {
diags->debug_client_ip.load(ip_string);
- else
+ } else {
diags->debug_client_ip.invalidate();
+ }
}
static int
diff --git a/proxy/http/HttpConnectionCount.cc b/proxy/http/HttpConnectionCount.cc
index faf1b9f..015310a 100644
--- a/proxy/http/HttpConnectionCount.cc
+++ b/proxy/http/HttpConnectionCount.cc
@@ -51,8 +51,9 @@ ConnectionCount::dumpToJSON()
appendJSONPair(oss, "connection_count", _hostCount.get(keys[i]));
oss << "}";
- if (i < keys.n - 1)
+ if (i < keys.n - 1) {
oss << ',';
+ }
}
ink_mutex_release(&_mutex);
oss << "]}";
diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc
index ee5769d..ce78934 100644
--- a/proxy/http/HttpTransact.cc
+++ b/proxy/http/HttpTransact.cc
@@ -652,8 +652,9 @@ HttpTransact::StartRemapRequest(State *s)
if (s->http_config_param->referer_filter_enabled) {
s->filter_mask = URL_REMAP_FILTER_REFERER;
- if (s->http_config_param->referer_format_redirect)
+ if (s->http_config_param->referer_format_redirect) {
s->filter_mask |= URL_REMAP_FILTER_REDIRECT_FMT;
+ }
}
TxnDebug("http_trans", "END HttpTransact::StartRemapRequest");
diff --git a/proxy/http/HttpTransactHeaders.cc b/proxy/http/HttpTransactHeaders.cc
index c0d7998..52f97fd 100644
--- a/proxy/http/HttpTransactHeaders.cc
+++ b/proxy/http/HttpTransactHeaders.cc
@@ -719,8 +719,9 @@ HttpTransactHeaders::write_hdr_protocol_stack(char *hdr_string, size_t len, Prot
memcpy(hdr, "http", 4);
hdr += 4;
- if (tls_p)
+ if (tls_p) {
*hdr++ = 's';
+ }
// If detail level is compact (RFC 7239 compliant "proto" value for Forwarded field), stop here.
diff --git a/proxy/http/remap/RemapProcessor.cc b/proxy/http/remap/RemapProcessor.cc
index 8619941..e22b710 100644
--- a/proxy/http/remap/RemapProcessor.cc
+++ b/proxy/http/remap/RemapProcessor.cc
@@ -226,8 +226,9 @@ RemapProcessor::finish_remap(HttpTransact::State *s, UrlRewrite *table)
if (*redirect_url == nullptr) {
*redirect_url = ats_strdup(map->filter_redirect_url ? map->filter_redirect_url : table->http_default_redirect_url);
}
- if (HTTP_STATUS_NONE == s->http_return_code)
+ if (HTTP_STATUS_NONE == s->http_return_code) {
s->http_return_code = HTTP_STATUS_MOVED_TEMPORARILY;
+ }
return false;
}
}
diff --git a/proxy/logging/LogObject.cc b/proxy/logging/LogObject.cc
index 740b4b9..867810f 100644
--- a/proxy/logging/LogObject.cc
+++ b/proxy/logging/LogObject.cc
@@ -1134,8 +1134,9 @@ LogObjectManager::preproc_buffers(int idx)
bool
LogObjectManager::unmanage_api_object(LogObject *logObject)
{
- if (!logObject)
+ if (!logObject) {
return false;
+ }
ACQUIRE_API_MUTEX("A LogObjectManager::unmanage_api_object");
--
To stop receiving notification emails like this one, please contact
bcall@apache.org.