Skip to content

Commit

Permalink
squash some -Wformat compiler warnings
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Smattr committed Apr 12, 2020
1 parent 34dea49 commit 44492d2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
4 changes: 2 additions & 2 deletions gatb-core/src/gatb/kmer/impl/CountProcessorHistogram.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class CountProcessorHistogram : public CountProcessorAbstract<span>
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");
}
Expand All @@ -134,7 +134,7 @@ class CountProcessorHistogram : public CountProcessorAbstract<span>
//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");
}

Expand Down
22 changes: 7 additions & 15 deletions gatb-core/src/gatb/tools/compression/HeaderCoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define PRINT_DEBUG_ENCODER
#define PRINT_DEBUG_DECODER
*/
#include <string>


//====================================================================================
Expand Down Expand Up @@ -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
}

Expand All @@ -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
}

Expand All @@ -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
}

Expand Down
3 changes: 2 additions & 1 deletion gatb-core/thirdparty/BooPHF/BooPHF.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#pragma once
#include <stdio.h>
#include <cinttypes>
#include <climits>
#include <stdlib.h>
#include <iostream>
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 44492d2

Please sign in to comment.