diff --git a/example/plugins/c-api/ssl_preaccept/ssl_preaccept.cc b/example/plugins/c-api/ssl_preaccept/ssl_preaccept.cc index d5805844f14..be662ad29b1 100644 --- a/example/plugins/c-api/ssl_preaccept/ssl_preaccept.cc +++ b/example/plugins/c-api/ssl_preaccept/ssl_preaccept.cc @@ -39,7 +39,7 @@ namespace { -typedef std::pair IpRange; +using IpRange = std::pair; using IpRangeQueue = std::deque; IpRangeQueue ClientBlindTunnelIp; diff --git a/iocore/cache/test/main.cc b/iocore/cache/test/main.cc index 7c57a0cc638..3585ab68bea 100644 --- a/iocore/cache/test/main.cc +++ b/iocore/cache/test/main.cc @@ -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(this->info.request_get()), old_info); return 0; } @@ -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(this->info.request_get()), &this->params); return 0; } diff --git a/plugins/background_fetch/background_fetch.cc b/plugins/background_fetch/background_fetch.cc index cc5c7fd3e1f..ba6837265e2 100644 --- a/plugins/background_fetch/background_fetch.cc +++ b/plugins/background_fetch/background_fetch.cc @@ -55,7 +55,7 @@ static const std::array 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 OutstandingRequests; +using OutstandingRequests = std::unordered_map; class BgFetchState { diff --git a/plugins/cache_range_requests/cache_range_requests.cc b/plugins/cache_range_requests/cache_range_requests.cc index 5b43d45fc16..cb294e8058c 100644 --- a/plugins/cache_range_requests/cache_range_requests.cc +++ b/plugins/cache_range_requests/cache_range_requests.cc @@ -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}; diff --git a/plugins/escalate/escalate.cc b/plugins/escalate/escalate.cc index 32663bdb447..71bc3944b7b 100644 --- a/plugins/escalate/escalate.cc +++ b/plugins/escalate/escalate.cc @@ -49,7 +49,7 @@ struct EscalationState { std::string target; }; - typedef std::map StatusMapType; + using StatusMapType = std::map; EscalationState() { diff --git a/plugins/esi/esi.cc b/plugins/esi/esi.cc index b92da0c5224..9d223b5f997 100644 --- a/plugins/esi/esi.cc +++ b/plugins/esi/esi.cc @@ -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(body.size())); post_request.append(buf); post_request.append(body); diff --git a/plugins/esi/test/parser_test.cc b/plugins/esi/test/parser_test.cc index c200eeb2cb3..f2b3873f3c9 100644 --- a/plugins/esi/test/parser_test.cc +++ b/plugins/esi/test/parser_test.cc @@ -115,7 +115,7 @@ main() { cout << endl << "==================== Test 6: Invalid Quoted URL test " << endl; EsiParser parser("parser_test", &Debug, &Error); - string input_data = ""; + string input_data = R"()"; DocNodeList node_list; assert(parser.parseChunk(input_data, node_list) == false); diff --git a/plugins/esi/test/utils_test.cc b/plugins/esi/test/utils_test.cc index 9c1e059d875..924ff936dc4 100644 --- a/plugins/esi/test/utils_test.cc +++ b/plugins/esi/test/utils_test.cc @@ -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); @@ -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); diff --git a/plugins/experimental/access_control/utils.cc b/plugins/experimental/access_control/utils.cc index cd212d11506..53911e463b3 100644 --- a/plugins/experimental/access_control/utils.cc +++ b/plugins/experimental/access_control/utils.cc @@ -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; } diff --git a/plugins/experimental/cache_fill/background_fetch.cc b/plugins/experimental/cache_fill/background_fetch.cc index ba749074102..2b4a655dad1 100644 --- a/plugins/experimental/cache_fill/background_fetch.cc +++ b/plugins/experimental/cache_fill/background_fetch.cc @@ -38,7 +38,7 @@ #include "ts/ts.h" #include "ts/remap.h" #include "background_fetch.h" -typedef std::unordered_map OutstandingRequests; +using OutstandingRequests = std::unordered_map; /////////////////////////////////////////////////////////////////////////// // Set a header to a specific value. This will avoid going to through a diff --git a/plugins/experimental/cache_fill/cache_fill.cc b/plugins/experimental/cache_fill/cache_fill.cc index 0165e5f1fe5..17b8607381e 100644 --- a/plugins/experimental/cache_fill/cache_fill.cc +++ b/plugins/experimental/cache_fill/cache_fill.cc @@ -68,11 +68,12 @@ getCacheLookupResultName(TSCacheLookupResult result) static bool cont_check_cacheable(TSHttpTxn txnp) { - if (TSHttpTxnIsInternal(txnp)) + if (TSHttpTxnIsInternal(txnp)) { return false; + } int lookupStatus; TSHttpTxnCacheLookupStatusGet(txnp, &lookupStatus); - TSDebug(PLUGIN_NAME, "lookup status: %s", getCacheLookupResultName((TSCacheLookupResult)lookupStatus)); + TSDebug(PLUGIN_NAME, "lookup status: %s", getCacheLookupResultName(static_cast(lookupStatus))); bool ret = false; if (TS_CACHE_LOOKUP_MISS == lookupStatus || TS_CACHE_LOOKUP_HIT_STALE == lookupStatus) { bool const nostore = TSHttpTxnServerRespNoStoreGet(txnp); diff --git a/plugins/experimental/collapsed_forwarding/collapsed_forwarding.cc b/plugins/experimental/collapsed_forwarding/collapsed_forwarding.cc index 9033f4e9e2d..b5063e90ad8 100644 --- a/plugins/experimental/collapsed_forwarding/collapsed_forwarding.cc +++ b/plugins/experimental/collapsed_forwarding/collapsed_forwarding.cc @@ -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) diff --git a/plugins/experimental/cookie_remap/cookie_remap.cc b/plugins/experimental/cookie_remap/cookie_remap.cc index 5515497ca00..ceef473d55f 100644 --- a/plugins/experimental/cookie_remap/cookie_remap.cc +++ b/plugins/experimental/cookie_remap/cookie_remap.cc @@ -811,8 +811,8 @@ class op TSHttpStatus else_status = TS_HTTP_STATUS_NONE; }; -typedef std::pair StringPair; -using OpMap = std::vector; +using StringPair = std::pair; +using OpMap = std::vector; //---------------------------------------------------------------------------- static bool diff --git a/plugins/experimental/magick/magick.cc b/plugins/experimental/magick/magick.cc index d320d017045..24cd0f584c8 100644 --- a/plugins/experimental/magick/magick.cc +++ b/plugins/experimental/magick/magick.cc @@ -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; diff --git a/plugins/experimental/maxmind_acl/mmdb.cc b/plugins/experimental/maxmind_acl/mmdb.cc index 95ab3b0b4fa..7c1d7c3c055 100644 --- a/plugins/experimental/maxmind_acl/mmdb.cc +++ b/plugins/experimental/maxmind_acl/mmdb.cc @@ -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(), false); + for (auto &&i : country) { + allow_country.insert_or_assign(i.as(), false); } } else { TSDebug(PLUGIN_NAME, "Invalid country code allow list yaml"); @@ -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()}, min, max); + ats_ip_range_parse(std::string_view{i.as()}, min, max); deny_ip_map.fill(min, max, nullptr); TSDebug(PLUGIN_NAME, "loading ip: valid: %d, fam %d ", min.isValid(), min.family()); } @@ -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(), true); + for (auto &&i : country) { + allow_country.insert_or_assign(i.as(), true); } } else { @@ -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()}, min, max); + ats_ip_range_parse(std::string_view{i.as()}, min, max); allow_ip_map.fill(min, max, nullptr); TSDebug(PLUGIN_NAME, "loading ip: valid: %d, fam %d ", min.isValid(), min.family()); } @@ -290,9 +290,9 @@ Acl::parseregex(const YAML::Node ®ex, 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>(); + auto temprule = i.as>(); temp._regex_s = temprule.back(); const char *error; int erroffset; @@ -311,11 +311,11 @@ Acl::parseregex(const YAML::Node ®ex, 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().c_str()); + TSDebug(PLUGIN_NAME, "Adding regex: %s, for country: %s", temp._regex_s.c_str(), i[y].as().c_str()); if (allow) { - allow_regex[regex[i][y].as()].push_back(temp); + allow_regex[i[y].as()].push_back(temp); } else { - deny_regex[regex[i][y].as()].push_back(temp); + deny_regex[i[y].as()].push_back(temp); } } } @@ -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 @@ -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); } @@ -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(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); diff --git a/plugins/experimental/memcache/tsmemcache.cc b/plugins/experimental/memcache/tsmemcache.cc index 532c2bb4b31..4440670d836 100644 --- a/plugins/experimental/memcache/tsmemcache.cc +++ b/plugins/experimental/memcache/tsmemcache.cc @@ -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((intptr_t)data))); return EVENT_CONT; } } diff --git a/plugins/experimental/mysql_remap/mysql_remap.cc b/plugins/experimental/mysql_remap/mysql_remap.cc index f2c69b26486..2d1551af6e1 100644 --- a/plugins/experimental/mysql_remap/mysql_remap.cc +++ b/plugins/experimental/mysql_remap/mysql_remap.cc @@ -28,9 +28,9 @@ MYSQL mysql; -typedef struct { +using my_data = struct { char *query; -} my_data; +}; bool do_mysql_remap(TSCont contp, TSHttpTxn txnp) diff --git a/plugins/experimental/rate_limit/rate_limit.cc b/plugins/experimental/rate_limit/rate_limit.cc index c05a4862225..1d0d669cbb5 100644 --- a/plugins/experimental/rate_limit/rate_limit.cc +++ b/plugins/experimental/rate_limit/rate_limit.cc @@ -17,7 +17,7 @@ */ #include #include -#include +#include #include #include diff --git a/plugins/experimental/statichit/statichit.cc b/plugins/experimental/statichit/statichit.cc index c20fb364013..4c5c6d4f902 100644 --- a/plugins/experimental/statichit/statichit.cc +++ b/plugins/experimental/statichit/statichit.cc @@ -522,7 +522,7 @@ StaticHitTxnHook(TSCont contp, TSEvent event, void *edata) } method = TSHttpHdrMethodGet(bufp, hdr_loc, &method_length); - if (NULL == method) { + if (nullptr == method) { VERROR("Couldn't retrieve client request method"); goto done; } @@ -601,9 +601,9 @@ TSReturnCode TSRemapNewInstance(int argc, char *argv[], void **ih, char * /* errbuf ATS_UNUSED */, int /* errbuf_size ATS_UNUSED */) { static const struct option longopt[] = { - {"file-path", required_argument, NULL, 'f'}, {"mime-type", required_argument, NULL, 'm'}, - {"max-age", required_argument, NULL, 'a'}, {"failure-code", required_argument, NULL, 'c'}, - {"success-code", required_argument, NULL, 's'}, {NULL, no_argument, NULL, '\0'}}; + {"file-path", required_argument, nullptr, 'f'}, {"mime-type", required_argument, nullptr, 'm'}, + {"max-age", required_argument, nullptr, 'a'}, {"failure-code", required_argument, nullptr, 'c'}, + {"success-code", required_argument, nullptr, 's'}, {nullptr, no_argument, nullptr, '\0'}}; std::string filePath; std::string mimeType = "text/plain"; @@ -616,7 +616,7 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char * /* errbuf ATS_UNUSE optind = 0; while (true) { - int opt = getopt_long(argc, (char *const *)argv, "f:m:a:c:s:", longopt, NULL); + int opt = getopt_long(argc, (char *const *)argv, "f:m:a:c:s:", longopt, nullptr); switch (opt) { case 'f': { @@ -646,7 +646,7 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char * /* errbuf ATS_UNUSE return TS_ERROR; } - if (filePath.find("/") != 0) { + if (filePath.find('/') != 0) { filePath = std::string(TSConfigDirGet()) + '/' + filePath; } diff --git a/plugins/experimental/stream_editor/stream_editor.cc b/plugins/experimental/stream_editor/stream_editor.cc index 0bd7d8a8839..e6e524e95cc 100644 --- a/plugins/experimental/stream_editor/stream_editor.cc +++ b/plugins/experimental/stream_editor/stream_editor.cc @@ -551,7 +551,7 @@ class rule_t using ruleset_t = std::vector; using rule_p = ruleset_t::const_iterator; -typedef struct contdata_t { +using contdata_t = struct contdata_t { TSCont cont = nullptr; TSIOBuffer out_buf = nullptr; TSIOBufferReader out_rd = nullptr; @@ -582,7 +582,7 @@ typedef struct contdata_t { contbuf_sz = 2 * sz - 1; } } -} contdata_t; +}; static int64_t process_block(contdata_t *contdata, TSIOBufferReader reader) diff --git a/plugins/header_rewrite/conditions_geo_maxmind.cc b/plugins/header_rewrite/conditions_geo_maxmind.cc index 5e0e76c5d20..27912db1de2 100644 --- a/plugins/header_rewrite/conditions_geo_maxmind.cc +++ b/plugins/header_rewrite/conditions_geo_maxmind.cc @@ -114,7 +114,7 @@ MMConditionGeo::get_geo_string(const sockaddr *addr) const } ret = std::string(entry_data.utf8_string, entry_data.data_size); - if (NULL != entry_data_list) { + if (nullptr != entry_data_list) { MMDB_free_entry_data_list(entry_data_list); } @@ -176,7 +176,7 @@ MMConditionGeo::get_geo_int(const sockaddr *addr) const } ret = entry_data.uint32; - if (NULL != entry_data_list) { + if (nullptr != entry_data_list) { MMDB_free_entry_data_list(entry_data_list); } diff --git a/plugins/header_rewrite/header_rewrite.cc b/plugins/header_rewrite/header_rewrite.cc index 09593eacab4..221c550adea 100644 --- a/plugins/header_rewrite/header_rewrite.cc +++ b/plugins/header_rewrite/header_rewrite.cc @@ -302,7 +302,7 @@ cont_rewrite_headers(TSCont contp, TSEvent event, void *edata) return 0; } -static const struct option longopt[] = {{"geo-db-path", required_argument, NULL, 'm'}, {NULL, no_argument, NULL, '\0'}}; +static const struct option longopt[] = {{"geo-db-path", required_argument, nullptr, 'm'}, {nullptr, no_argument, nullptr, '\0'}}; /////////////////////////////////////////////////////////////////////////////// // Initialize the InkAPI plugin for the global hooks we support. @@ -323,7 +323,7 @@ TSPluginInit(int argc, const char *argv[]) std::string geoDBpath; while (true) { - int opt = getopt_long(argc, (char *const *)argv, "m:", longopt, NULL); + int opt = getopt_long(argc, const_cast(argv), "m:", longopt, nullptr); switch (opt) { case 'm': { @@ -335,7 +335,7 @@ TSPluginInit(int argc, const char *argv[]) } } - if (!geoDBpath.empty() && geoDBpath.find("/") != 0) { + if (!geoDBpath.empty() && geoDBpath.find('/') != 0) { geoDBpath = std::string(TSConfigDirGet()) + '/' + geoDBpath; } @@ -421,7 +421,7 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char * /* errbuf ATS_UNUSE std::string geoDBpath; while (true) { - int opt = getopt_long(argc, (char *const *)argv, "m:", longopt, NULL); + int opt = getopt_long(argc, (char *const *)argv, "m:", longopt, nullptr); switch (opt) { case 'm': { @@ -434,7 +434,7 @@ TSRemapNewInstance(int argc, char *argv[], void **ih, char * /* errbuf ATS_UNUSE } if (!geoDBpath.empty()) { - if (geoDBpath.find("/") != 0) { + if (geoDBpath.find('/') != 0) { geoDBpath = std::string(TSConfigDirGet()) + '/' + geoDBpath; } diff --git a/plugins/multiplexer/ats-multiplexer.cc b/plugins/multiplexer/ats-multiplexer.cc index 8a814d88758..e192c31a9c2 100644 --- a/plugins/multiplexer/ats-multiplexer.cc +++ b/plugins/multiplexer/ats-multiplexer.cc @@ -78,7 +78,7 @@ TSRemapNewInstance(int argc, char **argv, void **i, char *, int) instance->skipPostPut = false; if (argc > 2) { - std::copy_if(argv + 2, argv + argc, std::back_inserter(instance->origins), [&](std::string s) { + std::copy_if(argv + 2, argv + argc, std::back_inserter(instance->origins), [&](const std::string &s) { if (s == "proxy.config.multiplexer.skip_post_put=1") { instance->skipPostPut = true; return false; diff --git a/proxy/CacheControl.cc b/proxy/CacheControl.cc index 91749f181ac..f1ed4e2429f 100644 --- a/proxy/CacheControl.cc +++ b/proxy/CacheControl.cc @@ -59,7 +59,7 @@ static const char *CC_directive_str[CC_NUM_TYPES] = { // "CACHE_AUTH_CONTENT" }; -typedef ControlMatcher CC_table; +using CC_table = ControlMatcher; // Global Ptrs static Ptr reconfig_mutex; diff --git a/proxy/ParentSelection.cc b/proxy/ParentSelection.cc index 3d38dcd268c..5f9182160a5 100644 --- a/proxy/ParentSelection.cc +++ b/proxy/ParentSelection.cc @@ -35,7 +35,7 @@ #define MAX_SIMPLE_RETRIES 5 #define MAX_UNAVAILABLE_SERVER_RETRIES 5 -typedef ControlMatcher P_table; +using P_table = ControlMatcher; // Global Vars for Parent Selection static const char modulePrefix[] = "[ParentSelection]"; diff --git a/proxy/hdrs/HuffmanCodec.cc b/proxy/hdrs/HuffmanCodec.cc index 562fa36b88a..546269042c6 100644 --- a/proxy/hdrs/HuffmanCodec.cc +++ b/proxy/hdrs/HuffmanCodec.cc @@ -70,11 +70,11 @@ static const huffman_entry huffman_table[] = { {0x7ffffe8, 27}, {0x7ffffe9, 27}, {0x7ffffea, 27}, {0x7ffffeb, 27}, {0xffffffe, 28}, {0x7ffffec, 27}, {0x7ffffed, 27}, {0x7ffffee, 27}, {0x7ffffef, 27}, {0x7fffff0, 27}, {0x3ffffee, 26}, {0x3fffffff, 30}}; -typedef struct node { +using Node = struct node { node *left, *right; char ascii_code; bool leaf_node; -} Node; +}; Node *HUFFMAN_TREE_ROOT; diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc index d6aa87444eb..8e121af1946 100644 --- a/proxy/http/HttpTransact.cc +++ b/proxy/http/HttpTransact.cc @@ -7664,7 +7664,7 @@ HttpTransact::build_request(State *s, HTTPHdr *base_request, HTTPHdr *outgoing_r URL *url = outgoing_request->url_get(); // Remove fragment from upstream URL - url->fragment_set(NULL, 0); + url->fragment_set(nullptr, 0); // Check whether a Host header field is missing from a 1.0 or 1.1 request. if (outgoing_version != HTTP_0_9 && !outgoing_request->presence(MIME_PRESENCE_HOST)) { diff --git a/proxy/http2/HPACK.cc b/proxy/http2/HPACK.cc index 09d1a531e9f..7a5c73d30cf 100644 --- a/proxy/http2/HPACK.cc +++ b/proxy/http2/HPACK.cc @@ -33,7 +33,7 @@ namespace // its value's length in octets, and 32. const static unsigned ADDITIONAL_OCTETS = 32; -typedef enum { +using TS_HPACK_STATIC_TABLE_ENTRY = enum { TS_HPACK_STATIC_TABLE_0 = 0, TS_HPACK_STATIC_TABLE_AUTHORITY, TS_HPACK_STATIC_TABLE_METHOD_GET, @@ -97,7 +97,7 @@ typedef enum { TS_HPACK_STATIC_TABLE_VIA, TS_HPACK_STATIC_TABLE_WWW_AUTHENTICATE, TS_HPACK_STATIC_TABLE_ENTRY_NUM -} TS_HPACK_STATIC_TABLE_ENTRY; +}; constexpr HpackHeaderField STATIC_TABLE[] = {{"", ""}, {":authority", ""}, diff --git a/proxy/logging/LogField.cc b/proxy/logging/LogField.cc index c884cc296d1..34d23dd187f 100644 --- a/proxy/logging/LogField.cc +++ b/proxy/logging/LogField.cc @@ -171,7 +171,7 @@ struct cmp_str { }; } // namespace -typedef std::map milestone_map; +using milestone_map = std::map; static milestone_map m_milestone_map; struct milestone { diff --git a/src/traffic_crashlog/traffic_crashlog.cc b/src/traffic_crashlog/traffic_crashlog.cc index de954ecf418..936ccefda75 100644 --- a/src/traffic_crashlog/traffic_crashlog.cc +++ b/src/traffic_crashlog/traffic_crashlog.cc @@ -192,8 +192,8 @@ main(int /* argc ATS_UNUSED */, const char **argv) diags->config.outputs[DL_Emergency].to_syslog = true; } - Note("crashlog started, target=%ld, debug=%s syslog=%s, uid=%ld euid=%ld", (long)target_pid, debug_mode ? "true" : "false", - syslog_mode ? "true" : "false", (long)getuid(), (long)geteuid()); + Note("crashlog started, target=%ld, debug=%s syslog=%s, uid=%ld euid=%ld", static_cast(target_pid), + debug_mode ? "true" : "false", syslog_mode ? "true" : "false", (long)getuid(), (long)geteuid()); mgmterr = TSInit(nullptr, (TSInitOptionT)(TS_MGMT_OPT_NO_EVENTS | TS_MGMT_OPT_NO_SOCK_TESTS)); if (mgmterr != TS_ERR_OKAY) { diff --git a/src/traffic_ctl/config.cc b/src/traffic_ctl/config.cc index d60cb3a07d0..e3433392310 100644 --- a/src/traffic_ctl/config.cc +++ b/src/traffic_ctl/config.cc @@ -369,8 +369,8 @@ CtrlEngine::config_status() CTRL_MGMT_CHECK(manager.fetch("proxy.node.config.restart_required.manager")); std::cout << CtrlMgmtRecordValue(version).c_str() << std::endl; - std::cout << "Started at " << timestr((time_t)starttime.as_int()).c_str(); - std::cout << "Last reconfiguration at " << timestr((time_t)configtime.as_int()).c_str(); + std::cout << "Started at " << timestr(static_cast(starttime.as_int())).c_str(); + std::cout << "Last reconfiguration at " << timestr(static_cast(configtime.as_int())).c_str(); std::cout << (reconfig.as_int() ? "Reconfiguration required" : "Configuration is current") << std::endl; if (proxy.as_int()) { diff --git a/src/traffic_logstats/logstats.cc b/src/traffic_logstats/logstats.cc index c581e1f223a..ae75bac1121 100644 --- a/src/traffic_logstats/logstats.cc +++ b/src/traffic_logstats/logstats.cc @@ -389,9 +389,9 @@ class UrlLru _dump_url(u, as_object); } if (as_object) { - std::cout << " \"_timestamp\" : \"" << static_cast(ink_time_wall_seconds()) << "\"" << std::endl; + std::cout << R"( "_timestamp" : ")" << static_cast(ink_time_wall_seconds()) << "\"" << std::endl; } else { - std::cout << " { \"_timestamp\" : \"" << static_cast(ink_time_wall_seconds()) << "\" }" << std::endl; + std::cout << R"( { "_timestamp" : ")" << static_cast(ink_time_wall_seconds()) << "\" }" << std::endl; } } @@ -1929,8 +1929,8 @@ format_elapsed_line(const char *desc, const ElapsedStats &stat, bool json, bool if (json) { std::cout << " " << '"' << desc << "\" : " << "{ "; - std::cout << "\"min\": \"" << stat.min << "\", "; - std::cout << "\"max\": \"" << stat.max << "\""; + std::cout << R"("min": ")" << stat.min << "\", "; + std::cout << R"("max": ")" << stat.max << "\""; if (!concise) { std::cout << ", \"avg\": \"" << std::setiosflags(ios::fixed) << std::setprecision(2) << stat.avg << "\", "; std::cout << "\"dev\": \"" << std::setiosflags(ios::fixed) << std::setprecision(2) << stat.stddev << "\""; @@ -1968,12 +1968,12 @@ format_line(const char *desc, const StatsCounter &stat, const StatsCounter &tota if (json) { std::cout << " " << '"' << desc << "\" : " << "{ "; - std::cout << "\"req\": \"" << stat.count << "\", "; + std::cout << R"("req": ")" << stat.count << "\", "; if (!concise) { std::cout << "\"req_pct\": \"" << std::setiosflags(ios::fixed) << std::setprecision(2) << (double)stat.count / total.count * 100 << "\", "; } - std::cout << "\"bytes\": \"" << stat.bytes << "\""; + std::cout << R"("bytes": ")" << stat.bytes << "\""; if (!concise) { std::cout << ", \"bytes_pct\": \"" << std::setiosflags(ios::fixed) << std::setprecision(2) @@ -2260,7 +2260,7 @@ print_detail_stats(const OriginStats *stat, bool json, bool concise) std::cout << std::endl; std::cout << std::setw(cl.line_len) << std::setfill('_') << '_' << std::setfill(' ') << std::endl; } else { - std::cout << " \"_timestamp\" : \"" << static_cast(ink_time_wall_seconds()) << '"' << std::endl; + std::cout << R"( "_timestamp" : ")" << static_cast(ink_time_wall_seconds()) << '"' << std::endl; } } diff --git a/src/traffic_server/Crash.cc b/src/traffic_server/Crash.cc index d91f3fbbc06..fa3195880c9 100644 --- a/src/traffic_server/Crash.cc +++ b/src/traffic_server/Crash.cc @@ -158,7 +158,7 @@ crash_logger_invoke(int signo, siginfo_t *info, void *ctx) // ucontext_t can contain pointers, so it's highly platform dependent. On Linux with glibc, however, it is // a single memory block that we can just puke out. ATS_UNUSED_RETURN(write(crash_logger_fd, info, sizeof(siginfo_t))); - ATS_UNUSED_RETURN(write(crash_logger_fd, (ucontext_t *)ctx, sizeof(ucontext_t))); + ATS_UNUSED_RETURN(write(crash_logger_fd, static_cast(ctx), sizeof(ucontext_t))); #endif close(crash_logger_fd); diff --git a/src/traffic_server/InkAPI.cc b/src/traffic_server/InkAPI.cc index 21495c1dbe3..6a26a0eeed3 100644 --- a/src/traffic_server/InkAPI.cc +++ b/src/traffic_server/InkAPI.cc @@ -7910,7 +7910,7 @@ char * TSMatcherReadIntoBuffer(char *file_name, int *file_len) { sdk_assert(sdk_sanity_check_null_ptr((void *)file_name) == TS_SUCCESS); - return readIntoBuffer((char *)file_name, "TSMatcher", file_len); + return readIntoBuffer(file_name, "TSMatcher", file_len); } char * diff --git a/src/traffic_server/InkAPITest.cc b/src/traffic_server/InkAPITest.cc index 3405755723c..6f345159d02 100644 --- a/src/traffic_server/InkAPITest.cc +++ b/src/traffic_server/InkAPITest.cc @@ -3380,7 +3380,7 @@ checkHttpTxnServerRespGet(SocketTest *test, void *data) static int checkHttpTxnServerSsnTransactionCount(SocketTest *test, void *data) { - TSHttpTxn txnp = (TSHttpTxn)data; + TSHttpTxn txnp = static_cast(data); int count = TSHttpTxnServerSsnTransactionCount(txnp); if (count < 0) { diff --git a/src/traffic_server/SocksProxy.cc b/src/traffic_server/SocksProxy.cc index c1f44c25559..62799a04557 100644 --- a/src/traffic_server/SocksProxy.cc +++ b/src/traffic_server/SocksProxy.cc @@ -149,7 +149,7 @@ SocksProxy::init(NetVConnection *netVC) SCOPED_MUTEX_LOCK(lock, mutex, this_ethread()); - SET_HANDLER((EventHandler)&SocksProxy::acceptEvent); + SET_HANDLER(static_cast(&SocksProxy::acceptEvent)); handleEvent(NET_EVENT_ACCEPT, netVC); } @@ -178,7 +178,7 @@ SocksProxy::acceptEvent(int event, void *data) buf->reset(); - SET_HANDLER((EventHandler)&SocksProxy::mainEvent); + SET_HANDLER(static_cast(&SocksProxy::mainEvent)); vc_handler = &SocksProxy::state_read_client_request; timeout = this_ethread()->schedule_in(this, HRTIME_SECONDS(netProcessor.socks_conf_stuff->socks_timeout)); @@ -299,7 +299,7 @@ SocksProxy::state_read_client_request(int event, void *data) unsigned char *p = (unsigned char *)reader->start(); - Debug("SocksProxy", "Accepted connection from a version %d client", (int)p[0]); + Debug("SocksProxy", "Accepted connection from a version %d client", static_cast(p[0])); switch (p[0]) { case SOCKS4_VERSION: @@ -313,7 +313,7 @@ SocksProxy::state_read_client_request(int event, void *data) return (this->*vc_handler)(event, data); break; default: - Warning("Wrong version for Socks: %d\n", (int)p[0]); + Warning("Wrong version for Socks: %d\n", static_cast(p[0])); state = SOCKS_ERROR; break; } @@ -470,7 +470,7 @@ SocksProxy::state_read_socks5_client_request(int event, void *data) default: req_len = INT_MAX; state = SOCKS_ERROR; - Debug("SocksProxy", "Illegal address type(%d)", (int)p[3]); + Debug("SocksProxy", "Illegal address type(%d)", static_cast(p[3])); } if (state == SOCKS_ERROR) { diff --git a/src/tscore/ink_file.cc b/src/tscore/ink_file.cc index bd09666095f..6f054e7dbc1 100644 --- a/src/tscore/ink_file.cc +++ b/src/tscore/ink_file.cc @@ -56,11 +56,11 @@ #include /* for BLKGETSIZE. sys/mount.h is another candidate */ #endif -typedef union { +using ioctl_arg_t = union { uint64_t u64; uint32_t u32; off_t off; -} ioctl_arg_t; +}; int ink_fputln(FILE *stream, const char *s) diff --git a/src/tscore/ink_queue.cc b/src/tscore/ink_queue.cc index f4a2841c06f..7a528e2d58c 100644 --- a/src/tscore/ink_queue.cc +++ b/src/tscore/ink_queue.cc @@ -74,10 +74,10 @@ struct ink_freelist_ops { void (*fl_bulkfree)(InkFreeList *, void *, void *, size_t); }; -typedef struct _ink_freelist_list { +using ink_freelist_list = struct _ink_freelist_list { InkFreeList *fl; struct _ink_freelist_list *next; -} ink_freelist_list; +}; static void *freelist_new(InkFreeList *f); static void freelist_free(InkFreeList *f, void *item); diff --git a/src/tscore/unit_tests/test_layout.cc b/src/tscore/unit_tests/test_layout.cc index 736393bd847..1305d939db6 100644 --- a/src/tscore/unit_tests/test_layout.cc +++ b/src/tscore/unit_tests/test_layout.cc @@ -29,8 +29,9 @@ std::string append_slash(const char *path) { std::string ret(path); - if (ret.back() != '/') + if (ret.back() != '/') { ret.append("/"); + } return ret; }