Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/plugins/c-api/ssl_preaccept/ssl_preaccept.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

namespace
{
typedef std::pair<IpAddr, IpAddr> IpRange;
using IpRange = std::pair<IpAddr, IpAddr>;
using IpRangeQueue = std::deque<IpRange>;
IpRangeQueue ClientBlindTunnelIp;

Expand Down
4 changes: 2 additions & 2 deletions iocore/cache/test/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ CacheWriteTest::start_test(int event, void *e)
}

SET_HANDLER(&CacheWriteTest::write_event);
cacheProcessor.open_write(this, 0, &key, (CacheHTTPHdr *)this->info.request_get(), old_info);
cacheProcessor.open_write(this, 0, &key, static_cast<CacheHTTPHdr *>(this->info.request_get()), old_info);
return 0;
}

Expand Down Expand Up @@ -271,7 +271,7 @@ CacheReadTest::start_test(int event, void *e)
key = generate_key(this->info);

SET_HANDLER(&CacheReadTest::read_event);
cacheProcessor.open_read(this, &key, (CacheHTTPHdr *)this->info.request_get(), &this->params);
cacheProcessor.open_read(this, &key, static_cast<CacheHTTPHdr *>(this->info.request_get()), &this->params);
return 0;
}

Expand Down
6 changes: 3 additions & 3 deletions iocore/net/SSLSessionCache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ SSLOriginSessionCache::~SSLOriginSessionCache()
}

void
SSLOriginSessionCache::insert_session(std::string lookup_key, SSL_SESSION *sess)
SSLOriginSessionCache::insert_session(const std::string &lookup_key, SSL_SESSION *sess)
{
if (is_debug_tag_set("ssl.origin_session_cache")) {
Debug("ssl.origin_session_cache", "insert session: %s = %p", lookup_key.c_str(), sess);
Expand All @@ -327,7 +327,7 @@ SSLOriginSessionCache::insert_session(std::string lookup_key, SSL_SESSION *sess)
}

void
SSLOriginSessionCache::remove_session(std::string lookup_key)
SSLOriginSessionCache::remove_session(const std::string &lookup_key)
{
if (is_debug_tag_set("ssl.origin_session_cache")) {
Debug("ssl.origin_session_cache", "remove session: %s", lookup_key.c_str());
Expand All @@ -342,7 +342,7 @@ SSLOriginSessionCache::remove_session(std::string lookup_key)
}

SSL_SESSION *
SSLOriginSessionCache::get_session(std::string lookup_key)
SSLOriginSessionCache::get_session(const std::string &lookup_key)
{
if (is_debug_tag_set("ssl.origin_session_cache")) {
Debug("ssl.origin_session_cache", "get session: %s", lookup_key.c_str());
Expand Down
6 changes: 3 additions & 3 deletions iocore/net/SSLSessionCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,9 @@ class SSLOriginSessionCache
SSLOriginSessionCache();
~SSLOriginSessionCache();

void insert_session(std::string lookup_key, SSL_SESSION *sess);
void remove_session(std::string lookup_key);
SSL_SESSION *get_session(std::string lookup_key);
void insert_session(const std::string &lookup_key, SSL_SESSION *sess);
void remove_session(const std::string &lookup_key);
SSL_SESSION *get_session(const std::string &lookup_key);

private:
mutable std::shared_mutex mutex;
Expand Down
2 changes: 1 addition & 1 deletion plugins/background_fetch/background_fetch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ static const std::array<const std::string_view, 6> FILTER_HEADERS{
// Hold the global background fetch state. This is currently shared across all
// configurations, as a singleton. ToDo: Would it ever make sense to do this
// per remap rule? Maybe for per-remap logging ??
typedef std::unordered_map<std::string, bool> OutstandingRequests;
using OutstandingRequests = std::unordered_map<std::string, bool>;

class BgFetchState
{
Expand Down
4 changes: 2 additions & 2 deletions plugins/cache_range_requests/cache_range_requests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@

namespace
{
typedef enum parent_select_mode {
using parent_select_mode_t = enum parent_select_mode {
PS_DEFAULT, // Default ATS parent selection mode
PS_CACHEKEY_URL, // Set parent selection url to cache_key url
} parent_select_mode_t;
};

struct pluginconfig {
parent_select_mode_t ps_mode{PS_DEFAULT};
Expand Down
2 changes: 1 addition & 1 deletion plugins/escalate/escalate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct EscalationState {
std::string target;
};

typedef std::map<unsigned, RetryInfo> StatusMapType;
using StatusMapType = std::map<unsigned int, RetryInfo>;

EscalationState()
{
Expand Down
2 changes: 1 addition & 1 deletion plugins/esi/esi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ cacheNodeList(ContData *cont_data)
string body("");
cont_data->esi_proc->packNodeList(body, false);
char buf[64];
snprintf(buf, 64, "%s: %d\r\n\r\n", TS_MIME_FIELD_CONTENT_LENGTH, (int)body.size());
snprintf(buf, 64, "%s: %d\r\n\r\n", TS_MIME_FIELD_CONTENT_LENGTH, static_cast<int>(body.size()));

post_request.append(buf);
post_request.append(body);
Expand Down
2 changes: 1 addition & 1 deletion plugins/esi/test/parser_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ main()
{
cout << endl << "==================== Test 6: Invalid Quoted URL test " << endl;
EsiParser parser("parser_test", &Debug, &Error);
string input_data = "<esi:include src=abc\"\"de\"f />";
string input_data = R"(<esi:include src=abc""de"f />)";

DocNodeList node_list;
assert(parser.parseChunk(input_data, node_list) == false);
Expand Down
6 changes: 3 additions & 3 deletions plugins/esi/test/utils_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ main()
const char *expected_strs4[] = {"pos", " SKY BAR ", "spaceid", "12123", nullptr};
checkAttributes("test4", attr_list, expected_strs4);

string str5("a=\"b & xyz\"&c=d&e=f&g=h\"");
string str5(R"(a="b & xyz"&c=d&e=f&g=h")");
Utils::parseAttributes(str5, attr_list, "&");
const char *expected_strs5[] = {"a", "b & xyz", "c", "d", "e", "f", nullptr};
checkAttributes("test5", attr_list, expected_strs5);
Expand All @@ -91,9 +91,9 @@ main()
checkAttributes("test7", attr_list, expected_strs7);

const char *escaped_sequence = R"({\"site-attribute\":\"content=no_expandable; ajax_cert_expandable\"})";
string str8("pos=\"FPM1\" spaceid=96584352 extra_mime=\"");
string str8(R"(pos="FPM1" spaceid=96584352 extra_mime=")");
str8.append(escaped_sequence);
str8.append("\" foo=bar a=\"b\"");
str8.append(R"(" foo=bar a="b")");
const char *expected_strs8[] = {"pos", "FPM1", "spaceid", "96584352", "extra_mime", escaped_sequence,
"foo", "bar", "a", "b", nullptr};
Utils::parseAttributes(str8, attr_list);
Expand Down
2 changes: 1 addition & 1 deletion plugins/experimental/access_control/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ cryptoMessageDigestGet(const char *digestType, const char *data, size_t dataLen,
#else
ctx = HMAC_CTX_new();
#endif
if (!HMAC_Init_ex(ctx, key, keyLen, md, NULL)) {
if (!HMAC_Init_ex(ctx, key, keyLen, md, nullptr)) {
AccessControlError("failed to create EVP message digest context: %s", cryptoErrStr(buffer, sizeof(buffer)));
goto err;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ static int OPEN_WRITE_FAIL_REQ_DELAY_TIMEOUT = 500;

static bool global_init = false;

typedef struct _RequestData {
using RequestData = struct _RequestData {
TSHttpTxn txnp;
int wl_retry; // write lock failure retry count
std::string req_url;
} RequestData;
};

static int
add_redirect_header(TSMBuffer &bufp, TSMLoc &hdr_loc, const std::string &location)
Expand Down
4 changes: 2 additions & 2 deletions plugins/experimental/cookie_remap/cookie_remap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -811,8 +811,8 @@ class op
TSHttpStatus else_status = TS_HTTP_STATUS_NONE;
};

typedef std::pair<std::string, std::string> StringPair;
using OpMap = std::vector<StringPair>;
using StringPair = std::pair<std::string, std::string>;
using OpMap = std::vector<StringPair>;

//----------------------------------------------------------------------------
static bool
Expand Down
2 changes: 1 addition & 1 deletion plugins/experimental/magick/magick.cc
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ struct ImageTransform : TransformationPlugin {
{
TSDebug(PLUGIN_TAG, "handleInputComplete");

threadPool_.emplace_back([this](void) {
threadPool_.emplace_back([this]() {
magick::Image image;
magick::Exception exception;
magick::Wand wand;
Expand Down
32 changes: 16 additions & 16 deletions plugins/experimental/maxmind_acl/mmdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ Acl::loaddeny(const YAML::Node &denyNode)
YAML::Node country = denyNode["country"];
if (!country.IsNull()) {
if (country.IsSequence()) {
for (std::size_t i = 0; i < country.size(); i++) {
allow_country.insert_or_assign(country[i].as<std::string>(), false);
for (auto &&i : country) {
allow_country.insert_or_assign(i.as<std::string>(), false);
}
} else {
TSDebug(PLUGIN_NAME, "Invalid country code allow list yaml");
Expand All @@ -170,9 +170,9 @@ Acl::loaddeny(const YAML::Node &denyNode)
if (!ip.IsNull()) {
if (ip.IsSequence()) {
// Do IP Deny processing
for (std::size_t i = 0; i < ip.size(); i++) {
for (auto &&i : ip) {
IpAddr min, max;
ats_ip_range_parse(std::string_view{ip[i].as<std::string>()}, min, max);
ats_ip_range_parse(std::string_view{i.as<std::string>()}, min, max);
deny_ip_map.fill(min, max, nullptr);
TSDebug(PLUGIN_NAME, "loading ip: valid: %d, fam %d ", min.isValid(), min.family());
}
Expand Down Expand Up @@ -230,8 +230,8 @@ Acl::loadallow(const YAML::Node &allowNode)
YAML::Node country = allowNode["country"];
if (!country.IsNull()) {
if (country.IsSequence()) {
for (std::size_t i = 0; i < country.size(); i++) {
allow_country.insert_or_assign(country[i].as<std::string>(), true);
for (auto &&i : country) {
allow_country.insert_or_assign(i.as<std::string>(), true);
}

} else {
Expand All @@ -251,9 +251,9 @@ Acl::loadallow(const YAML::Node &allowNode)
if (!ip.IsNull()) {
if (ip.IsSequence()) {
// Do IP Allow processing
for (std::size_t i = 0; i < ip.size(); i++) {
for (auto &&i : ip) {
IpAddr min, max;
ats_ip_range_parse(std::string_view{ip[i].as<std::string>()}, min, max);
ats_ip_range_parse(std::string_view{i.as<std::string>()}, min, max);
allow_ip_map.fill(min, max, nullptr);
TSDebug(PLUGIN_NAME, "loading ip: valid: %d, fam %d ", min.isValid(), min.family());
}
Expand Down Expand Up @@ -290,9 +290,9 @@ Acl::parseregex(const YAML::Node &regex, bool allow)
if (!regex.IsNull()) {
if (regex.IsSequence()) {
// Parse each country-regex pair
for (std::size_t i = 0; i < regex.size(); i++) {
for (const auto &i : regex) {
plugin_regex temp;
auto temprule = regex[i].as<std::vector<std::string>>();
auto temprule = i.as<std::vector<std::string>>();
temp._regex_s = temprule.back();
const char *error;
int erroffset;
Expand All @@ -311,11 +311,11 @@ Acl::parseregex(const YAML::Node &regex, bool allow)
}

for (std::size_t y = 0; y < temprule.size() - 1; y++) {
TSDebug(PLUGIN_NAME, "Adding regex: %s, for country: %s", temp._regex_s.c_str(), regex[i][y].as<std::string>().c_str());
TSDebug(PLUGIN_NAME, "Adding regex: %s, for country: %s", temp._regex_s.c_str(), i[y].as<std::string>().c_str());
if (allow) {
allow_regex[regex[i][y].as<std::string>()].push_back(temp);
allow_regex[i[y].as<std::string>()].push_back(temp);
} else {
deny_regex[regex[i][y].as<std::string>()].push_back(temp);
deny_regex[i[y].as<std::string>()].push_back(temp);
}
}
}
Expand Down Expand Up @@ -423,7 +423,7 @@ Acl::eval(TSRemapRequestInfo *rri, TSHttpTxn txnp)
return ret;
}

if (NULL != entry_data_list) {
if (nullptr != entry_data_list) {
// This is useful to be able to dump out a full record of a
// mmdb entry for debug. Enabling can help if you want to figure
// out how to add new fields
Expand Down Expand Up @@ -481,7 +481,7 @@ Acl::eval(TSRemapRequestInfo *rri, TSHttpTxn txnp)
break;
}

if (NULL != entry_data_list) {
if (nullptr != entry_data_list) {
MMDB_free_entry_data_list(entry_data_list);
}

Expand All @@ -498,7 +498,7 @@ Acl::eval_country(MMDB_entry_data_s *entry_data, const char *path, int path_len)
bool ret = false;
bool allow = default_allow;
char *output = nullptr;
output = (char *)malloc((sizeof(char) * entry_data->data_size));
output = static_cast<char *>(malloc((sizeof(char) * entry_data->data_size)));
strncpy(output, entry_data->utf8_string, entry_data->data_size);
TSDebug(PLUGIN_NAME, "This IP Country Code: %s", output);
auto exists = allow_country.count(output);
Expand Down
6 changes: 3 additions & 3 deletions plugins/experimental/memcache/tsmemcache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ MCAccept::main_event(int event, void *data)
}
return EVENT_CONT;
} else {
Fatal("tsmemcache accept received fatal error: errno = %d", -((int)(intptr_t)data));
Fatal("tsmemcache accept received fatal error: errno = %d", -(static_cast<int>((intptr_t)data)));
return EVENT_CONT;
}
}
Expand Down Expand Up @@ -224,10 +224,10 @@ MC::add_binary_header(uint16_t err, uint8_t hdr_len, uint16_t key_len, uint32_t

r.response.magic = static_cast<uint8_t>(PROTOCOL_BINARY_RES);
r.response.opcode = binary_header.request.opcode;
r.response.keylen = (uint16_t)htons(key_len);
r.response.keylen = static_cast<uint16_t>(htons(key_len));
r.response.extlen = hdr_len;
r.response.datatype = static_cast<uint8_t>(PROTOCOL_BINARY_RAW_BYTES);
r.response.status = (uint16_t)htons(err);
r.response.status = static_cast<uint16_t>(htons(err));
r.response.bodylen = htonl(body_len);
r.response.opaque = binary_header.request.opaque;
r.response.cas = ink_hton64(header.cas);
Expand Down
4 changes: 2 additions & 2 deletions plugins/experimental/mysql_remap/mysql_remap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@

MYSQL mysql;

typedef struct {
using my_data = struct {
char *query;
} my_data;
};

bool
do_mysql_remap(TSCont contp, TSHttpTxn txnp)
Expand Down
2 changes: 1 addition & 1 deletion plugins/experimental/parent_select/consistenthash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ constexpr std::string_view hash_key_path_fragment = "path+fragment";
constexpr std::string_view hash_key_cache = "cache_key";

PLHostRecord *
chash_lookup(std::shared_ptr<ATSConsistentHash> ring, uint64_t hash_key, ATSConsistentHashIter *iter, bool *wrapped,
chash_lookup(const std::shared_ptr<ATSConsistentHash> &ring, uint64_t hash_key, ATSConsistentHashIter *iter, bool *wrapped,
ATSHash64Sip24 *hash, bool *hash_init, bool *mapWrapped, uint64_t sm_id)
{
PLHostRecord *host_rec = nullptr;
Expand Down
17 changes: 8 additions & 9 deletions plugins/experimental/parent_select/consistenthash_config.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

#include "consistenthash_config.h"

void loadConfigFile(const std::string fileName, std::stringstream &doc, std::unordered_set<std::string> &include_once);
void loadConfigFile(const std::string &fileName, std::stringstream &doc, std::unordered_set<std::string> &include_once);

// createStrategy creates and initializes a Consistent Hash strategy from the given YAML node.
// Caller takes ownership of the returned pointer, and must call delete on it.
Expand Down Expand Up @@ -108,17 +108,16 @@ createStrategiesFromFile(const char *file)

// std::map<std::string, TSNextHopSelectionStrategy*, std::less<>>
strategies_map strategiesMap;
for (unsigned int i = 0; i < strategies.size(); ++i) {
YAML::Node strategy = strategies[i];
auto name = strategy["strategy"].as<std::string>();
for (auto &&strategy : strategies) {
auto name = strategy["strategy"].as<std::string>();
TSDebug(PLUGIN_NAME, "createStrategiesFromFile filename %s got strategy %s.", basename, name.c_str());
auto policy = strategy["policy"];
if (!policy) {
TSError("[%s] no policy is defined for the strategy named '%s'.", PLUGIN_NAME, name.c_str());
return strategies_map();
}
TSDebug(PLUGIN_NAME, "createStrategiesFromFile filename %s got strategy %s checked policy.", basename, name.c_str());
auto policy_value = policy.Scalar();
const auto &policy_value = policy.Scalar();
if (policy_value != consistent_hash) {
TSError("[%s] strategy named '%s' has unsupported policy '%s'.", PLUGIN_NAME, name.c_str(), policy_value.c_str());
return strategies_map();
Expand Down Expand Up @@ -149,7 +148,7 @@ createStrategiesFromFile(const char *file)
* 'strategy' yaml file would then normally have the '#include hosts.yml' in it's begining.
*/
void
loadConfigFile(const std::string fileName, std::stringstream &doc, std::unordered_set<std::string> &include_once)
loadConfigFile(const std::string &fileName, std::stringstream &doc, std::unordered_set<std::string> &include_once)
{
const char *sep = " \t";
char *tok, *last;
Expand Down Expand Up @@ -187,8 +186,8 @@ loadConfigFile(const std::string fileName, std::stringstream &doc, std::unordere
std::sort(files.begin(), files.end(),
[](const std::string_view lhs, const std::string_view rhs) { return lhs.compare(rhs) < 0; });

for (uint32_t i = 0; i < files.size(); i++) {
std::ifstream file(fileName + "/" + files[i].data());
for (auto &f : files) {
std::ifstream file(fileName + "/" + f.data());
if (file.is_open()) {
while (std::getline(file, line)) {
if (line[0] == '#') {
Expand All @@ -198,7 +197,7 @@ loadConfigFile(const std::string fileName, std::stringstream &doc, std::unordere
}
file.close();
} else {
throw std::invalid_argument("Unable to open and read '" + fileName + "/" + files[i].data() + "'");
throw std::invalid_argument("Unable to open and read '" + fileName + "/" + f.data() + "'");
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions plugins/experimental/parent_select/healthstatus.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
void
PLNextHopHealthStatus::insert(std::vector<std::shared_ptr<PLHostRecord>> &hosts)
{
for (uint32_t ii = 0; ii < hosts.size(); ii++) {
std::shared_ptr<PLHostRecord> h = hosts[ii];
for (auto h : hosts) {
for (auto protocol = h->protocols.begin(); protocol != h->protocols.end(); ++protocol) {
const std::string host_port = h->getHostPort((*protocol)->port);
host_map.emplace(std::make_pair(host_port, h));
Expand Down
Loading