From: Axel Viala Date: Sat, 1 Oct 2022 11:45:38 +0000 (+0200) Subject: [clang-tidy][geoip-backend] Use std::Array and constify weekday/months. X-Git-Tag: dnsdist-1.8.0-rc1~222^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77b1ccacf524360f722a067ab135fa4c35f603e8;p=thirdparty%2Fpdns.git [clang-tidy][geoip-backend] Use std::Array and constify weekday/months. --- diff --git a/modules/geoipbackend/geoipbackend.cc b/modules/geoipbackend/geoipbackend.cc index 0c523f79e8..89df74e115 100644 --- a/modules/geoipbackend/geoipbackend.cc +++ b/modules/geoipbackend/geoipbackend.cc @@ -62,8 +62,8 @@ struct GeoIPDomain static vector s_domains; static int s_rc = 0; // refcount - always accessed under lock -static string GeoIP_WEEKDAYS[] = {"mon", "tue", "wed", "thu", "fri", "sat", "sun"}; -static string GeoIP_MONTHS[] = {"jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"}; +const static std::array GeoIP_WEEKDAYS = {"mon", "tue", "wed", "thu", "fri", "sat", "sun"}; +const static std::array GeoIP_MONTHS = {"jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"}; /* So how does it work - we have static records and services. Static records "win". We also insert empty non terminals for records and services. @@ -757,12 +757,12 @@ string GeoIPBackend::format2str(string sformat, const Netmask& addr, GeoIPNetmas } else if (!sformat.compare(cur, 4, "%wds")) { nrep = 4; - rep = GeoIP_WEEKDAYS[gtm.tm_wday]; + rep = GeoIP_WEEKDAYS.at(gtm.tm_wday); tmp_gl.netmask = (addr.isIPv6() ? 128 : 32); } else if (!sformat.compare(cur, 4, "%mos")) { nrep = 4; - rep = GeoIP_MONTHS[gtm.tm_mon]; + rep = GeoIP_MONTHS.at(gtm.tm_mon); tmp_gl.netmask = (addr.isIPv6() ? 128 : 32); } else if (!sformat.compare(cur, 3, "%wd")) {