]> git.ipfire.org Git - thirdparty/pdns.git/blobdiff - pdns/sillyrecords.cc
Merge pull request #14200 from rgacogne/auth-enable-leak-detection-unit-tests
[thirdparty/pdns.git] / pdns / sillyrecords.cc
index d1319a1a4227e88125de9a5b3301691864c85dc3..cb97acc8fe493373de5cc5bade5d39d869ae2415 100644 (file)
 #include <cstdlib>
 #include <sys/types.h>
 #include <string>
-#include <errno.h>
+#include <cerrno>
 #include "dnsrecords.hh"
 
-static unsigned int poweroften[10] = {1, 10, 100, 1000, 10000, 100000,
-                                 1000000,10000000,100000000,1000000000};
+const static unsigned int poweroften[10] = {1, 10, 100, 1000, 10000, 100000,
+  1000000,10000000,100000000,1000000000};
 
 /* converts ascii size/precision X * 10**Y(cm) to 0xXY. moves pointer.*/
 static uint8_t precsize_aton(const char **strptr)
@@ -69,22 +69,22 @@ latlon2ul(const char **latlonstrptr, int *which)
 
   while (isdigit(*cp))
     deg = deg * 10 + (*cp++ - '0');
-  
+
   while (isspace(*cp))
     cp++;
-  
+
   if (!(isdigit(*cp)))
     goto fndhemi;
-  
+
   while (isdigit(*cp))
     min = min * 10 + (*cp++ - '0');
-    
+
   while (isspace(*cp))
     cp++;
-  
+
   if (*cp && !(isdigit(*cp)))
     goto fndhemi;
-  
+
   while (isdigit(*cp))
     secs = secs * 10 + (*cp++ - '0');
 
@@ -100,13 +100,13 @@ latlon2ul(const char **latlonstrptr, int *which)
       }
     }
   }
-  
+
   while (*cp && !isspace(*cp))   /* if any trailing garbage */
     cp++;
-  
+
   while (isspace(*cp))
     cp++;
-  
+
  fndhemi:
   switch (*cp) {
   case 'N': case 'n':
@@ -125,7 +125,7 @@ latlon2ul(const char **latlonstrptr, int *which)
     retval = 0;     /* invalid value -- indicates error */
     break;
   }
-  
+
   switch (*cp) {
   case 'N': case 'n':
   case 'S': case 's':
@@ -144,15 +144,15 @@ latlon2ul(const char **latlonstrptr, int *which)
     return 0;
 
   cp++;                   /* skip the hemisphere */
-  
+
   while (*cp && !isspace(*cp))   /* if any trailing garbage */
     cp++;
-  
+
   while (isspace(*cp))    /* move to next field */
     cp++;
-  
+
   *latlonstrptr = cp;
-  
+
   return (retval);
 }
 
@@ -168,7 +168,7 @@ std::shared_ptr<DNSRecordContent> LOCRecordContent::make(const string& content)
 }
 
 
-void LOCRecordContent::toPacket(DNSPacketWriter& pw)
+void LOCRecordContent::toPacket(DNSPacketWriter& pw) const
 {
   pw.xfr8BitInt(d_version);
   pw.xfr8BitInt(d_size);
@@ -180,7 +180,7 @@ void LOCRecordContent::toPacket(DNSPacketWriter& pw)
   pw.xfr32BitInt(d_altitude);
 }
 
-std::shared_ptr<LOCRecordContent::DNSRecordContent> LOCRecordContent::make(const DNSRecord &dr, PacketReader& pr) 
+std::shared_ptr<LOCRecordContent::DNSRecordContent> LOCRecordContent::make(const DNSRecord& /* dr */, PacketReader& pr)
 {
   auto ret=std::make_shared<LOCRecordContent>();
   pr.xfr8BitInt(ret->d_version);
@@ -191,18 +191,18 @@ std::shared_ptr<LOCRecordContent::DNSRecordContent> LOCRecordContent::make(const
   pr.xfr32BitInt(ret->d_latitude);
   pr.xfr32BitInt(ret->d_longitude);
   pr.xfr32BitInt(ret->d_altitude);
-  
+
   return ret;
 }
 
-LOCRecordContent::LOCRecordContent(const string& content, const string& zone) 
+LOCRecordContent::LOCRecordContent(const string& content, const string& /* zone */)
 {
   // 51 59 00.000 N 5 55 00.000 E 4.00m 1.00m 10000.00m 10.00m
   // convert this to d_version, d_size, d_horiz/vertpre, d_latitude, d_longitude, d_altitude
   d_version = 0;
 
   const char *cp, *maxcp;
-  
+
   uint32_t lltemp1 = 0, lltemp2 = 0;
   int altmeters = 0, altfrac = 0, altsign = 1;
   d_horizpre = 0x16;    /* default = 1e6 cm = 10000.00m = 10km */
@@ -240,10 +240,10 @@ LOCRecordContent::LOCRecordContent(const string& content, const string& zone)
 
   if (*cp == '+')
     cp++;
-  
+
   while (isdigit(*cp))
     altmeters = altmeters * 10 + (*cp++ - '0');
-  
+
   if (*cp == '.') {               /* decimal meters */
     cp++;
     if (isdigit(*cp)) {
@@ -253,50 +253,50 @@ LOCRecordContent::LOCRecordContent(const string& content, const string& zone)
       }
     }
   }
-  
+
   d_altitude = (10000000 + (altsign * (altmeters * 100 + altfrac)));
-  
+
   while (!isspace(*cp) && (cp < maxcp))
     /* if trailing garbage or m */
     cp++;
-  
+
   while (isspace(*cp) && (cp < maxcp))
     cp++;
-  
-  
+
+
   if (cp >= maxcp)
     goto defaults;
-  
+
   d_size = precsize_aton(&cp);
-  
+
   while (!isspace(*cp) && (cp < maxcp))/*if trailing garbage or m*/
     cp++;
-  
+
   while (isspace(*cp) && (cp < maxcp))
     cp++;
-  
+
   if (cp >= maxcp)
     goto defaults;
-  
+
   d_horizpre = precsize_aton(&cp);
-  
+
   while (!isspace(*cp) && (cp < maxcp))/*if trailing garbage or m*/
     cp++;
-  
+
   while (isspace(*cp) && (cp < maxcp))
     cp++;
-  
+
   if (cp >= maxcp)
     goto defaults;
-  
+
   d_vertpre = precsize_aton(&cp);
-  
+
  defaults:
   ;
 }
 
 
-string LOCRecordContent::getZoneRepresentation(bool noDot) const
+string LOCRecordContent::getZoneRepresentation(bool /* noDot */) const
 {
   // convert d_version, d_size, d_horiz/vertpre, d_latitude, d_longitude, d_altitude to:
   // 51 59 00.000 N 5 55 00.000 E 4.00m 1.00m 10000.00m 10.00m
@@ -304,7 +304,7 @@ string LOCRecordContent::getZoneRepresentation(bool noDot) const
   double latitude= ((int32_t)((uint32_t)d_latitude  - ((uint32_t)1<<31)))/3600000.0;
   double longitude=((int32_t)((uint32_t)d_longitude - ((uint32_t)1<<31)))/3600000.0;
   double altitude= ((int32_t)d_altitude           )/100.0 - 100000;
-  
+
   double size=0.01*((d_size>>4)&0xf);
   int count=d_size & 0xf;
   while(count--)