]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Merge pull request #9056 from omoerbeek/decl-warnings
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 28 Apr 2020 06:41:30 +0000 (08:41 +0200)
committerGitHub <noreply@github.com>
Tue, 28 Apr 2020 06:41:30 +0000 (08:41 +0200)
Add -Wmissing-declarations -Wredundant-decls

1  2 
pdns/lua-record.cc

diff --combined pdns/lua-record.cc
index ca46307a3727cef75e570df1a8e5d0000de38143,ee38aeb61bd761538f7c6e0e875489556a7832f5..ea43dcef1cddab2385f55da6896d1aabe397d314
@@@ -284,7 -284,7 +284,7 @@@ bool doCompare(const T& var, const std:
  }
  
  
- std::string getGeo(const std::string& ip, GeoIPInterface::GeoIPQueryAttribute qa)
+ static std::string getGeo(const std::string& ip, GeoIPInterface::GeoIPQueryAttribute qa)
  {
    static bool initialized;
    extern std::function<std::string(const std::string& ip, int)> g_getGeo;
@@@ -344,10 -344,6 +344,10 @@@ static ComboAddress pickwhashed(const C
      sum += i.first;
      pick.push_back({sum, i.second});
    }
 +  if (sum == 0) {
 +    /* we should not have any weight of zero, but better safe than sorry */
 +    return ComboAddress();
 +  }
    ComboAddress::addressOnlyHash aoh;
    int r = aoh(bestwho) % sum;
    auto p = upper_bound(pick.begin(), pick.end(), r, [](int rarg, const decltype(pick)::value_type& a) { return rarg < a.first; });
@@@ -372,7 -368,7 +372,7 @@@ static bool getLatLon(const std::string
    double latsec, lonsec;
    char lathem='X', lonhem='X';
  
 -  double lat, lon;
 +  double lat = 0, lon = 0;
    if(!getLatLon(ip, lat, lon))
      return false;
  
@@@ -531,12 -527,12 +531,12 @@@ typedef struct AuthLuaRecordContex
  
  static thread_local unique_ptr<lua_record_ctx_t> s_lua_record_ctx;
  
- void setupLuaRecords()
static void setupLuaRecords()
  {
    LuaContext& lua = *s_LUA->getLua();
  
    lua.writeFunction("latlon", []() {
 -      double lat, lon;
 +      double lat = 0, lon = 0;
        getLatLon(s_lua_record_ctx->bestwho.toString(), lat, lon);
        return std::to_string(lat)+" "+std::to_string(lon);
      });
        auto labels= s_lua_record_ctx->qname.getRawLabels();
        if(labels.size()<4)
          return std::string("unknown");
 -      double lat, lon;
 +      double lat = 0, lon = 0;
        getLatLon(labels[3]+"."+labels[2]+"."+labels[1]+"."+labels[0], lat, lon);
        return std::to_string(lat)+" "+std::to_string(lon);
      });