]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: Fix a 'temporary used in loop' warning reported by g++ 11.1.0 10429/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 19 May 2021 17:44:12 +0000 (19:44 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 19 May 2021 17:44:12 +0000 (19:44 +0200)
```
common_startup.cc: In function ‘void mainthread()’:
common_startup.cc:617:24: warning: loop variable ‘algotype’ of type ‘const string&’ {aka ‘const std::__cxx11::basic_string<char>&’} binds to a temporary constructed from type ‘const char* const’ [-Wrange-loop-construct]
  617 |     for (const string& algotype : {"ksk", "zsk"}) {
      |                        ^~~~~~~~
common_startup.cc:617:24: note: use non-reference type ‘const string’ {aka ‘const std::__cxx11::basic_string<char>’} to make the copy explicit or ‘const char* const&’ to prevent copying
```

pdns/common_startup.cc

index 88963c2a46460195c3c1b91eea8393db771d5b98..c3405964924dc447518d48bfeab343327f2eb4b2 100644 (file)
@@ -614,7 +614,7 @@ void mainthread()
     // Some sanity checking on default key settings
     bool hadKeyError = false;
     int kskAlgo{0}, zskAlgo{0};
-    for (const string& algotype : {"ksk", "zsk"}) {
+    for (const string algotype : {"ksk", "zsk"}) {
       int algo, size;
       if (::arg()["default-"+algotype+"-algorithm"].empty())
         continue;