]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
[clang-tidy][geoip-backend] Use std::Array and constify weekday/months.
authorAxel Viala <axel.viala@darnuria.eu>
Sat, 1 Oct 2022 11:45:38 +0000 (13:45 +0200)
committerAxel Viala <axel.viala@darnuria.eu>
Sun, 6 Nov 2022 12:45:55 +0000 (13:45 +0100)
modules/geoipbackend/geoipbackend.cc

index 0c523f79e8d616edb0e59d5e18ad1c1d60c84bf8..89df74e1154392b06e92f773b81ff0325fbee5ac 100644 (file)
@@ -62,8 +62,8 @@ struct GeoIPDomain
 static vector<GeoIPDomain> 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<string, 7> GeoIP_WEEKDAYS = {"mon", "tue", "wed", "thu", "fri", "sat", "sun"};
+const static std::array<string, 12> 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")) {