From 44492d201b3b2a3aa94cf989d66ff6648d8c6aae Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sun, 12 Apr 2020 11:12:18 -0700 Subject: [PATCH] squash some -Wformat compiler warnings Note that in some cases we now simply call C++11's std::to_string instead of using snprintf to build a temporary C string. --- .../kmer/impl/CountProcessorHistogram.hpp | 4 ++-- .../gatb/tools/compression/HeaderCoder.cpp | 22 ++++++------------- gatb-core/thirdparty/BooPHF/BooPHF.h | 3 ++- 3 files changed, 11 insertions(+), 18 deletions(-) diff --git a/gatb-core/src/gatb/kmer/impl/CountProcessorHistogram.hpp b/gatb-core/src/gatb/kmer/impl/CountProcessorHistogram.hpp index 43c71c92b..93dcda5ba 100644 --- a/gatb-core/src/gatb/kmer/impl/CountProcessorHistogram.hpp +++ b/gatb-core/src/gatb/kmer/impl/CountProcessorHistogram.hpp @@ -119,7 +119,7 @@ class CountProcessorHistogram : public CountProcessorAbstract fprintf(histo2Dfile,"%5i:\t",ii); for(int jj=0; jj<= _histogram->getLength2(); jj++) { - fprintf(histo2Dfile,"\t%6lli", _histogram->get2D(ii,jj)); + fprintf(histo2Dfile,"\t%6lli", (long long)_histogram->get2D(ii,jj)); } fprintf(histo2Dfile,"\n"); } @@ -134,7 +134,7 @@ class CountProcessorHistogram : public CountProcessorAbstract //output 1D histogram now for(int ii=1; ii<= _histogram->getLength(); ii++) { - fprintf(histo1Dfile,"%i\t%lli",ii,_histogram->get(ii)); + fprintf(histo1Dfile,"%i\t%lli",ii,(long long)_histogram->get(ii)); fprintf(histo1Dfile,"\n"); } diff --git a/gatb-core/src/gatb/tools/compression/HeaderCoder.cpp b/gatb-core/src/gatb/tools/compression/HeaderCoder.cpp index 2bc38adb5..ccbb2ea91 100644 --- a/gatb-core/src/gatb/tools/compression/HeaderCoder.cpp +++ b/gatb-core/src/gatb/tools/compression/HeaderCoder.cpp @@ -25,6 +25,7 @@ #define PRINT_DEBUG_ENCODER #define PRINT_DEBUG_DECODER */ +#include //==================================================================================== @@ -703,13 +704,10 @@ void HeaderDecoder::decodeNumeric(){ u_int64_t value = CompressionUtils::decodeNumeric(_rangeDecoder, _numericModels[_misIndex]); //_currentHeader += CompressionUtils::numberToString(value); - char temp[200]; - snprintf(temp,200,"%llu",value); - _currentHeader += string(temp); - //_currentHeader += to_string(value); // C++11 + _currentHeader += std::to_string(value); #ifdef PRINT_DEBUG_DECODER - cout << "\t\t\tAdding: " << string(temp) << endl; + cout << "\t\t\tAdding: " << std::to_string(value) << endl; #endif } @@ -723,13 +721,10 @@ void HeaderDecoder::decodeDelta(){ value = CompressionUtils::getValueFromDelta(1, _prevFieldValues[_fieldIndex], value); - char temp[200]; - snprintf(temp,200,"%llu",value); - _currentHeader += string(temp); - //_currentHeader += to_string(value); + _currentHeader += std::to_string(value); #ifdef PRINT_DEBUG_DECODER - cout << "\t\t\tAdding: " << string(temp) << endl; + cout << "\t\t\tAdding: " << std::to_string(value) << endl; #endif } @@ -742,13 +737,10 @@ void HeaderDecoder::decodeDelta2(){ u_int64_t value = CompressionUtils::decodeNumeric(_rangeDecoder, _numericModels[_misIndex]); value = CompressionUtils::getValueFromDelta(2, _prevFieldValues[_fieldIndex], value); - char temp[200]; - snprintf(temp,200,"%llu",value); - _currentHeader += string(temp); - //_currentHeader += to_string(value); + _currentHeader += std::to_string(value); #ifdef PRINT_DEBUG_DECODER - cout << "\t\t\tAdding: " << string(temp) << endl; + cout << "\t\t\tAdding: " << std::to_string(value) << endl; #endif } diff --git a/gatb-core/thirdparty/BooPHF/BooPHF.h b/gatb-core/thirdparty/BooPHF/BooPHF.h index 4c716cc30..5b445d578 100644 --- a/gatb-core/thirdparty/BooPHF/BooPHF.h +++ b/gatb-core/thirdparty/BooPHF/BooPHF.h @@ -4,6 +4,7 @@ #pragma once #include +#include #include #include #include @@ -836,7 +837,7 @@ we need this 2-functors scheme because HashFunctors won't work with unordered_ma uint64_t totalsize = totalsizeBitset + _final_hash.size()*42*8 ; // unordered map takes approx 42B per elem [personal test] (42B with uint64_t key, would be larger for other type of elem) - printf("Bitarray %12llu bits (%.2f %%) (array + ranks )\n", + printf("Bitarray %12" PRIu64 " bits (%.2f %%) (array + ranks )\n", totalsizeBitset, 100*(float)totalsizeBitset/totalsize); printf("final hash %12lu bits (%.2f %%) (nb in final hash %lu)\n", _final_hash.size()*42*8, 100*(float)(_final_hash.size()*42*8)/totalsize,