]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: fix compilation warnings by replacing snprintf with boost::format
authorCharles-Henri Bruyand <charles-henri.bruyand@open-xchange.com>
Mon, 17 Dec 2018 17:04:22 +0000 (18:04 +0100)
committerCharles-Henri Bruyand <charles-henri.bruyand@open-xchange.com>
Mon, 17 Dec 2018 17:05:39 +0000 (18:05 +0100)
pdns/rcpgenerator.cc
pdns/sillyrecords.cc

index 371158582f738e4deabd5145fc883b323a78507e..a21d1ab872e28dc41f4424b93b2e5ebabcbac455 100644 (file)
@@ -545,12 +545,7 @@ void RecordTextWriter::xfrTime(const uint32_t& val)
   time_t time=val; // Y2038 bug!
   gmtime_r(&time, &tm);
 
-  char tmp[16];
-  snprintf(tmp,sizeof(tmp)-1, "%04d%02d%02d" "%02d%02d%02d", 
-           tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, 
-           tm.tm_hour, tm.tm_min, tm.tm_sec);
-  
-  d_string += tmp;
+  d_string += boost::str(boost::format("%04d%02d%02d" "%02d%02d%02d") % (tm.tm_year+1900) % (tm.tm_mon+1) % tm.tm_mday % tm.tm_hour % tm.tm_min % tm.tm_sec);
 }
 
 
index d4030ef26559dce0679e662e63a3f06a5d4c4fe9..5b5d38a25bf07ec4e5e45ac6ba731f4ea90cb1b5 100644 (file)
@@ -319,15 +319,15 @@ string LOCRecordContent::getZoneRepresentation(bool noDot) const
 
   double remlat=60.0*(latitude-(int)latitude);
   double remlong=60.0*(longitude-(int)longitude);
-  char ret[80];
-  snprintf(ret,sizeof(ret)-1,"%d %d %2.03f %c %d %d %2.03f %c %.2fm %.2fm %.2fm %.2fm",
-           abs((int)latitude), abs((int) ((latitude-(int)latitude)*60)),
-           fabs((double)((remlat-(int)remlat)*60.0)),
-           latitude>0 ? 'N' : 'S',
-           abs((int)longitude), abs((int) ((longitude-(int)longitude)*60)),
-           fabs((double)((remlong-(int)remlong)*60.0)),
-           longitude>0 ? 'E' : 'W',
-           altitude, size, horizpre, vertpre);
+  std::string ret = boost::str(
+    boost::format("%d %d %2.03f %c %d %d %2.03f %c %.2fm %.2fm %.2fm %.2fm")
+    % abs((int)latitude) % abs((int) ((latitude-(int)latitude)*60))
+    % fabs((double)((remlat-(int)remlat)*60.0)) % (latitude>0 ? 'N' : 'S')
+    % abs((int)longitude) % abs((int) ((longitude-(int)longitude)*60))
+    % fabs((double)((remlong-(int)remlong)*60.0)) % (longitude>0 ? 'E' : 'W')
+    % altitude % size
+    % horizpre % vertpre
+    );
 
   return ret;
 }