This is an automated email from the ASF dual-hosted git repository. zwoop 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 b8172af4cc Fixes Cripts compilation on gcc platforms (#10729) b8172af4cc is described below commit b8172af4cca0f20c725dc9831f640b85d9e845ca Author: Leif Hedstrom <zw...@apache.org> AuthorDate: Tue Nov 7 09:08:47 2023 -0700 Fixes Cripts compilation on gcc platforms (#10729) --- example/cripts/CMakeLists.txt | 2 +- example/cripts/example1.cc | 2 +- include/cripts/Epilogue.hpp | 2 +- include/cripts/Lulu.hpp | 25 +++++++++++++++++++++++-- src/cripts/Geo.cc | 20 ++++---------------- src/cripts/Instance.cc | 2 +- src/cripts/Urls.cc | 2 +- 7 files changed, 32 insertions(+), 23 deletions(-) diff --git a/example/cripts/CMakeLists.txt b/example/cripts/CMakeLists.txt index dab7ce79a2..39174313d7 100644 --- a/example/cripts/CMakeLists.txt +++ b/example/cripts/CMakeLists.txt @@ -41,5 +41,5 @@ set(cript-includes -I${CMAKE_SOURCE_DIR}/include -I${CMAKE_SOURCE_DIR}/lib/swoc/ add_custom_target( cripts-clang-tidy COMMAND clang-tidy --config-file ${PROJECT_SOURCE_DIR}/tools/cripts/clang-tidy.conf --fix - ${PROJECT_SOURCE_DIR}/plugins/cripts/example1.cc -- -std=c++17 ${cript-includes} + ${PROJECT_SOURCE_DIR}/example/cripts/example1.cc -- -std=c++17 ${cript-includes} ) diff --git a/example/cripts/example1.cc b/example/cripts/example1.cc index 6261c599a8..9e07276f57 100644 --- a/example/cripts/example1.cc +++ b/example/cripts/example1.cc @@ -27,7 +27,7 @@ static Matcher::Range::IP CRIPT_ALLOW({"192.168.201.0/24", "10.0.0.0/8"}); // This is called only when the plugin is initialized do_init() { - TSDebug("Cript", "Hello, example1 plugin is being initialized"); + // TSDebug("Cript", "Hello, example1 plugin is being initialized"); } do_create_instance() diff --git a/include/cripts/Epilogue.hpp b/include/cripts/Epilogue.hpp index 71c728ea5d..6f9cd57a16 100644 --- a/include/cripts/Epilogue.hpp +++ b/include/cripts/Epilogue.hpp @@ -387,7 +387,7 @@ TSRemapInit(TSRemapInterface *api_info, char *errbuf, int errbuf_size) wrap_plugin_init(api_info, true, CaseArg); } - TSDebug("Cript", "Remap plugin %s is successfully initialized", __BASE_FILE__); + // TSDebug("Cript", "Remap plugin %s is successfully initialized", __BASE_FILE__); return TS_SUCCESS; } diff --git a/include/cripts/Lulu.hpp b/include/cripts/Lulu.hpp index 5d8bc36950..912d88f6d8 100644 --- a/include/cripts/Lulu.hpp +++ b/include/cripts/Lulu.hpp @@ -271,15 +271,36 @@ class string : public std::string using self_type = string; public: - using std::string::string; // ToDo: Why can't I use super_type:: here ? - using super_type::operator=; + using std::string::string; + // ToDo: This broke when switching to swoc::TextView // using std::string::operator Cript::string_view; using super_type::operator+=; using super_type::operator[]; + self_type& operator=(const self_type& str) + { + super_type::operator=(str); + return *this; + } + + self_type& operator=(const Cript::string_view& str) + { + super_type::operator=(str); + return *this; + } + + self_type& operator=(const char *str) + { + super_type::operator=(str); + return *this; + } + + string(const self_type &that) : super_type(that) {} + // This allows for a std::string to be moved to a Cript::string string(super_type &&that) : super_type(std::move(that)) {} + string(self_type &&that) : super_type(std::move(that)) {} // ToDo: This seems to be ambiquous with STL implementation // operator Cript::string_view() const { return {this->c_str(), this->size()}; } diff --git a/src/cripts/Geo.cc b/src/cripts/Geo.cc index 7a3455ba7e..2bc3c38f8a 100644 --- a/src/cripts/Geo.cc +++ b/src/cripts/Geo.cc @@ -33,40 +33,29 @@ enum Qualifiers { Cript::string get_geo_string(const sockaddr *addr, Qualifiers q) { + ink_release_assert(gMaxMindDB != nullptr); + ink_release_assert(addr != nullptr); + Cript::string ret = "(unknown)"; int mmdb_error; - if (gMaxMindDB == nullptr) { - TSDebug("Cripts", "MaxMind not initialized; using default value"); - return ret; - } - - if (addr == nullptr) { - TSDebug("Cripts", "client addr not initialized; using default value"); - return ret; - } - MMDB_lookup_result_s result = MMDB_lookup_sockaddr(gMaxMindDB, addr, &mmdb_error); if (MMDB_SUCCESS != mmdb_error) { - TSDebug("Cripts", "Error during sockaddr lookup: %s", MMDB_strerror(mmdb_error)); return ret; } MMDB_entry_data_list_s *entry_data_list = nullptr; if (!result.found_entry) { - TSDebug("Cripts", "No entry for this IP was found"); return ret; } int status = MMDB_get_entry_data_list(&result.entry, &entry_data_list); if (MMDB_SUCCESS != status) { - TSDebug("Cripts", "Error looking up entry data: %s", MMDB_strerror(status)); return ret; } if (entry_data_list == nullptr) { - TSDebug("Cripts", "No data found"); return ret; } @@ -79,7 +68,7 @@ get_geo_string(const sockaddr *addr, Qualifiers q) field_name = "autonomous_system_organization"; break; default: - TSDebug("Cripts", "Unsupported field %d", q); + Error("Cripts: Unsupported field %d", q); return ret; break; } @@ -88,7 +77,6 @@ get_geo_string(const sockaddr *addr, Qualifiers q) status = MMDB_get_value(&result.entry, &entry_data, field_name, NULL); if (MMDB_SUCCESS != status) { - TSDebug("Cripts", "Error on get value ASN value: %s", MMDB_strerror(status)); return ret; } ret = Cript::string(entry_data.utf8_string, entry_data.data_size); diff --git a/src/cripts/Instance.cc b/src/cripts/Instance.cc index aed923587e..1ef13c02c5 100644 --- a/src/cripts/Instance.cc +++ b/src/cripts/Instance.cc @@ -46,7 +46,7 @@ Cript::Instance::initialize(int argc, char *argv[], const char *filename) } if (period != Cript::string::npos) { - plugin_debug_tag = plugin_debug_tag.substr(slash + 1, period - slash - 1); + plugin_debug_tag = std::string_view(plugin_debug_tag.substr(slash + 1, period - slash - 1)); } dbg_ctl_cript.set(plugin_debug_tag.c_str()); diff --git a/src/cripts/Urls.cc b/src/cripts/Urls.cc index a46fe0b902..4102e8f92c 100644 --- a/src/cripts/Urls.cc +++ b/src/cripts/Urls.cc @@ -103,7 +103,7 @@ Url::Path::getSV() std::copy(_segments.begin(), _segments.end(), std::ostream_iterator<Cript::string_view>(path, "/")); _storage.reserve(_size); - _storage = path.str(); + _storage = std::string_view(path.str()); if (_storage.size() > 0) { _storage.pop_back(); // Removes the trailing / }