From: Charles-Henri Bruyand Date: Mon, 17 Dec 2018 17:04:22 +0000 (+0100) Subject: rec: fix compilation warnings by replacing snprintf with boost::format X-Git-Tag: rec-4.2.0-alpha1~49^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0e12635d6975731441ae27e5b98f070ecfb0cf8a;p=thirdparty%2Fpdns.git rec: fix compilation warnings by replacing snprintf with boost::format --- diff --git a/pdns/rcpgenerator.cc b/pdns/rcpgenerator.cc index 371158582f..a21d1ab872 100644 --- a/pdns/rcpgenerator.cc +++ b/pdns/rcpgenerator.cc @@ -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); } diff --git a/pdns/sillyrecords.cc b/pdns/sillyrecords.cc index d4030ef265..5b5d38a25b 100644 --- a/pdns/sillyrecords.cc +++ b/pdns/sillyrecords.cc @@ -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; }