Commit 2606292d authored by edrezen's avatar edrezen
Browse files

Use -Wall (minus a few warning options) and correct many (minor)

warnings
parent af21e957
......@@ -107,12 +107,15 @@ endif()
################################################################################
# GENERAL DEFINITIONS
################################################################################
set (LIB_COMPILE_WARNINGS "-Wall -Wno-unused-function -Wno-unused-variable -Wno-parentheses -Wno-format -Wno-strict-aliasing")
if (debug)
#set (LIBRARY_COMPILE_DEFINITIONS "${LIBRARY_COMPILE_DEFINITIONS} -g -p -pg")
set (LIBRARY_COMPILE_DEFINITIONS "${LIBRARY_COMPILE_DEFINITIONS} -g -p")
set (LIBRARY_COMPILE_DEFINITIONS "${LIBRARY_COMPILE_DEFINITIONS} -g -p ${LIB_COMPILE_WARNINGS}")
message("-- COMPILATION IN DEBUG MODE")
else()
set (LIBRARY_COMPILE_DEFINITIONS "${LIBRARY_COMPILE_DEFINITIONS} -O3")
set (LIBRARY_COMPILE_DEFINITIONS "${LIBRARY_COMPILE_DEFINITIONS} -O3 ${LIB_COMPILE_WARNINGS}")
endif()
if (INT128_FOUND)
......
......@@ -143,14 +143,14 @@ void BankBinary::insert (const Sequence& seq)
char* pt_start = seq.getDataBuffer();
char* pt_end = pt_start + whole_readlen;
int readlen;
int readlen = 0;
int tai = readlen;
unsigned char rbin;
unsigned int block_size = 0;
char *pt;
char * pt_begin = pt_start;
int idx =0 ;
size_t idx =0 ;
for ( ; pt_begin < pt_end; pt_begin += idx)
{
......@@ -364,9 +364,9 @@ bool BankBinary::check (const std::string& uri)
** REMARKS :
*********************************************************************/
BankBinary::Iterator::Iterator (BankBinary& ref)
: _ref(ref), _isDone(true), cpt_buffer(0), blocksize_toread(0), nseq_lues(0),
read_write_buffer_size(BINREADS_BUFFER), binary_read_file(0),
_bufferData (0), _index(0)
: _ref(ref), _isDone(true), _bufferData (0), cpt_buffer(0), blocksize_toread(0), nseq_lues(0),
binary_read_file(0),
_index(0)
{
}
......@@ -450,7 +450,7 @@ void BankBinary::Iterator::next ()
/** We are about to read another chunk of data from the disk. We need */
setBufferData (new Data (block_size));
size_t nbRead = fread (_bufferData->getBuffer(), sizeof( char),block_size, binary_read_file); // read a block of reads into the buffer
fread (_bufferData->getBuffer(), sizeof( char),block_size, binary_read_file); // read a block of reads into the buffer
cpt_buffer = 0;
blocksize_toread = block_size;
......@@ -529,7 +529,7 @@ void BankBinary::Iterator::estimate (u_int64_t& number, u_int64_t& totalSize, u
loop += sizeof(int) + (readlen+3)/4;
number ++;
if (readlen > maxSize) { maxSize = readlen; }
if (readlen > (int)maxSize) { maxSize = readlen; }
totalSize += readlen;
}
......@@ -551,7 +551,6 @@ void BankBinary::Iterator::estimate (u_int64_t& number, u_int64_t& totalSize, u
// we extrapolate the result
number = (number * end) / current;
maxSize = (maxSize * end) / current;
totalSize = (totalSize * end) / current;
}
......
......@@ -164,8 +164,6 @@ public:
int blocksize_toread;
int nseq_lues;
unsigned int read_write_buffer_size;
FILE* binary_read_file;
size_t _index;
......@@ -180,7 +178,7 @@ protected:
unsigned char* buffer;
int cpt_buffer;
unsigned int read_write_buffer_size;
int read_write_buffer_size;
FILE* binary_read_file;
void open (bool write);
......
......@@ -65,7 +65,10 @@ typedef struct
void rewind ()
{
gzrewind (stream);
last_char = eof = buffer_start = buffer_end = 0;
last_char = 0;
eof = 0;
buffer_start = 0;
buffer_end = 0;
}
} buffered_file_t;
......@@ -269,8 +272,7 @@ void BankFasta::insert (const Sequence& item)
char* loop = line;
size_t actualDataLineSize = _dataLineSize > 0 ? _dataLineSize : (size_t)(~0);
size_t len = item.getDataSize();
const char* buffer = item.getDataBuffer();
size_t len = item.getDataSize();
for (size_t i=0; i<len; )
{
......@@ -299,7 +301,8 @@ void BankFasta::insert (const Sequence& item)
** REMARKS :
*********************************************************************/
BankFasta::Iterator::Iterator (BankFasta& ref, CommentMode_e commentMode)
: _ref(ref), _commentsMode(commentMode), _isDone(true), index_file(0), buffered_file(0), buffered_strings(0), _index(0), _isInitialized(false), _nIters(0)
: _ref(ref), _commentsMode(commentMode), _isDone(true), _isInitialized(false), _nIters(0),
index_file(0), buffered_file(0), buffered_strings(0), _index(0)
{
DEBUG (("Bank::Iterator::Iterator\n"));
......@@ -319,7 +322,7 @@ BankFasta::Iterator::Iterator (BankFasta& ref, CommentMode_e commentMode)
BankFasta::Iterator::~Iterator ()
{
DEBUG (("Bank::Iterator::~Iterator\n"));
terminate ();
finalize ();
}
/*********************************************************************
......@@ -335,7 +338,7 @@ void BankFasta::Iterator::first()
/** We may have to initialize the instance. */
init ();
for (int i = 0; i < _ref.nb_files; i++)
for (u_int64_t i = 0; i < _ref.nb_files; i++)
{
buffered_file_t* bf = (buffered_file_t *) buffered_file[i];
if (bf != 0) { bf->rewind(); }
......@@ -594,7 +597,7 @@ bool BankFasta::Iterator::get_next_seq (Vector<char>& data, string& comment,stri
if (success) return true;
// cycle to next file if possible
if (index_file < _ref.nb_files - 1)
if ((u_int64_t)index_file < _ref.nb_files - 1)
{
index_file++;
return get_next_seq (data, comment,quality, mode);
......@@ -649,7 +652,7 @@ void BankFasta::Iterator::init ()
if ((*bf)->stream == NULL)
{
/** We first try do do some cleanup. */
terminate ();
finalize ();
/** We launch an exception. */
throw gatb::core::system::ExceptionErrno (STR_BANK_unable_open_file, fname);
......@@ -675,7 +678,13 @@ void BankFasta::Iterator::init ()
*********************************************************************/
void BankFasta::Iterator::finalize ()
{
for (int i = 0; i < _ref.nb_files; i++)
if (_isInitialized == false) { return; }
buffered_strings_t* bs = (buffered_strings_t*) buffered_strings;
if (bs != 0) { delete bs; }
for (u_int64_t i = 0; i < _ref.nb_files; i++)
{
buffered_file_t* bf = (buffered_file_t *) buffered_file[i];
if (bf != 0)
......@@ -684,27 +693,8 @@ void BankFasta::Iterator::finalize ()
if (bf->stream != NULL) { gzclose (bf->stream); bf->stream = 0; }
}
}
}
/*********************************************************************
** METHOD :
** PURPOSE :
** INPUT :
** OUTPUT :
** RETURN :
** REMARKS :
*********************************************************************/
void BankFasta::Iterator::terminate ()
{
if (_isInitialized == false) { return; }
buffered_strings_t* bs = (buffered_strings_t*) buffered_strings;
if (bs != 0) { delete bs; }
finalize();
for (int i = 0; i < _ref.nb_files; i++)
for (u_int64_t i = 0; i < _ref.nb_files; i++)
{
buffered_file_t* bf = (buffered_file_t *) buffered_file[i];
......@@ -724,6 +714,8 @@ void BankFasta::Iterator::terminate ()
/** We release the array of files. */
FREE (buffered_file);
/** We reset the initialization flag. */
_isInitialized = false;
}
/*********************************************************************
......@@ -742,7 +734,7 @@ void BankFasta::Iterator::estimate (u_int64_t& number, u_int64_t& totalSize, u_i
Vector<char> data;
/** We rewind the files. */
for (int i = 0; i < _ref.nb_files; i++)
for (u_int64_t i = 0; i < _ref.nb_files; i++)
{
buffered_file_t* bf = (buffered_file_t *) buffered_file[i];
if (bf != 0) { bf->rewind(); }
......@@ -765,7 +757,7 @@ void BankFasta::Iterator::estimate (u_int64_t& number, u_int64_t& totalSize, u_i
/** We compute the aggregated size from the files having been read until we
* reached our limit number of sequences. */
for (size_t i=0; i<=index_file; i++)
for (int i=0; i<=index_file; i++)
{
buffered_file_t* current = (buffered_file_t *) buffered_file[i];
......
......@@ -192,9 +192,6 @@ public:
/** Finish method. */
void finalize ();
/** Finish method. */
void terminate ();
int index_file; // index of current file
void** buffered_file;
......@@ -223,7 +220,7 @@ protected:
std::vector<std::string> _filenames;
u_int64_t filesizes; // estimate of total size for all files
int nb_files; // total nb of files
size_t nb_files; // total nb of files
/** File handle for inserting sequences into the bank. */
FILE* _insertHandle;
......
......@@ -128,7 +128,7 @@ void BankRandom::Iterator::first()
*********************************************************************/
void BankRandom::Iterator::next()
{
_isDone = (++_rank >= _bank._nbSequences);
_isDone = (++_rank >= (int64_t)_bank._nbSequences);
if (!_isDone)
{
static char table[] = {'A', 'C', 'T', 'G' };
......
......@@ -104,8 +104,8 @@ void BankSplitter::estimate (u_int64_t& number, u_int64_t& totalSize, u_int64_t&
** REMARKS :
*********************************************************************/
BankSplitter::Iterator::Iterator(const BankSplitter& bank)
: _dataRef (0), _rank(0), _nbMax(0), _isDone(true), _itRef(0),
_readMeanSize (bank._readMeanSize), _overlap(bank._overlap)
: _dataRef (0), _itRef(0), _readMeanSize (bank._readMeanSize),
_rank(0), _nbMax(0), _overlap(bank._overlap), _isDone(true)
{
assert (bank._readMeanSize > 0);
assert (bank._readMeanSize > bank._overlap);
......
......@@ -292,9 +292,6 @@ struct build_visitor : public boost::static_visitor<> {
template<size_t span> void operator() (GraphData<span>& data) const
{
/** Shortcuts. */
typedef typename Kmer<span>::Type Type;
typedef typename Kmer<span>::Count Count;
LOCAL (bank);
size_t kmerSize = props->get(STR_KMER_SIZE) ? props->getInt(STR_KMER_SIZE) : 31;
......@@ -581,7 +578,7 @@ Graph Graph::create (bank::IBank* bank, const char* fmt, ...)
char* buffer = 0;
va_list args;
va_start (args, fmt);
int res = vasprintf (&buffer, fmt, args);
vasprintf (&buffer, fmt, args);
va_end (args);
if (buffer != NULL) { commandLine = buffer; FREE (buffer); }
......@@ -614,7 +611,7 @@ Graph Graph::create (const char* fmt, ...)
char* buffer = 0;
va_list args;
va_start (args, fmt);
int res = vasprintf (&buffer, fmt, args);
vasprintf (&buffer, fmt, args);
va_end (args);
if (buffer != NULL) { commandLine = buffer; FREE (buffer); }
......@@ -663,8 +660,6 @@ Graph::Graph (const std::string& uri)
: _storageMode(PRODUCT_MODE_DEFAULT), _storage(0),
_variant(new GraphDataVariant()), _kmerSize(0), _info("graph"), _name(System::file().getBaseName(uri))
{
size_t precision = 0;
/** We create a storage instance. */
setStorage (StorageFactory(_storageMode).create (uri, false, false));
......@@ -694,8 +689,8 @@ Graph::Graph (const std::string& uri)
*********************************************************************/
Graph::Graph (bank::IBank* bank, tools::misc::IProperties* params)
: _storageMode(PRODUCT_MODE_DEFAULT), _storage(0),
_state(Graph::STATE_INIT_DONE),
_variant(new GraphDataVariant()), _kmerSize(0), _info("graph")
_variant(new GraphDataVariant()), _kmerSize(0), _info("graph"),
_state(Graph::STATE_INIT_DONE)
{
/** We get the kmer size from the user parameters. */
_kmerSize = params->getInt (STR_KMER_SIZE);
......@@ -729,8 +724,8 @@ Graph::Graph (bank::IBank* bank, tools::misc::IProperties* params)
*********************************************************************/
Graph::Graph (tools::misc::IProperties* params)
: _storageMode(PRODUCT_MODE_DEFAULT), _storage(0),
_state(Graph::STATE_INIT_DONE),
_variant(new GraphDataVariant()), _kmerSize(0), _info("graph")
_variant(new GraphDataVariant()), _kmerSize(0), _info("graph"),
_state(Graph::STATE_INIT_DONE)
{
/** We get the kmer size from the user parameters. */
_kmerSize = params->getInt (STR_KMER_SIZE);
......@@ -1678,9 +1673,7 @@ struct nodes_visitor : public boost::static_visitor<tools::dp::ISmartIterator<No
template<size_t span> tools::dp::ISmartIterator<NodeType>* operator() (const GraphData<span>& data) const
{
/** Shortcuts. */
typedef typename Kmer<span>::ModelCanonical Model;
typedef typename Kmer<span>::Type Type;
typedef typename Kmer<span>::Count Count;
typedef typename Kmer<span>::Count Count;
class NodeIterator : public tools::dp::ISmartIterator<NodeType>
{
......@@ -2414,7 +2407,6 @@ struct getNT_visitor : public boost::static_visitor<Nucleotide> {
template<size_t span> Nucleotide operator() (const GraphData<span>& data) const
{
/** Shortcuts. */
typedef typename Kmer<span>::ModelCanonical Model;
size_t kmerSize = data._model->getKmerSize();
if (node.strand == STRAND_FORWARD) { return (Nucleotide) (node.kmer[kmerSize-1-idx]); }
......
......@@ -117,7 +117,7 @@ struct Node
typedef tools::math::Integer Value;
/** Default constructor. */
Node () : abundance(0), strand(kmer::STRAND_FORWARD) {}
Node () : strand(kmer::STRAND_FORWARD), abundance(0) {}
/** Constructor.
* \param[in] kmer : kmer value. By default, it is the minimum value of the forward and revcomp value.
......@@ -853,8 +853,8 @@ private:
tools::storage::impl::Storage& getStorage() { return (*_storage); }
tools::storage::impl::Group& getGroup (const std::string name="") { return getStorage() (name); }
/** */
std::string _name;
/** Defined as a void* for hiding implementation in cpp file. */
void* _variant;
/** */
size_t _kmerSize;
......@@ -862,6 +862,11 @@ private:
/** Creation information. */
tools::misc::impl::Properties _info;
/** */
std::string _name;
State _state;
/** */
tools::misc::BloomKind _bloomKind;
tools::misc::DebloomKind _debloomKind;
......@@ -869,11 +874,6 @@ private:
tools::misc::BranchingKind _branchingKind;
tools::misc::MPHFKind _mphfKind;
State _state;
/** Defined as a void* for hiding implementation in cpp file. */
void* _variant;
/** */
Graph::Iterator<Node> getNodes () const;
......
......@@ -224,7 +224,7 @@ void IterativeExtensions<span>::construct_linear_seqs (
if (swf)
{
char* found = strstr (seq.getDataBuffer(), R.c_str());
if (found != NULL && ksd.depth > sizeKmer)
if (found != NULL && ksd.depth > (int)sizeKmer)
{
INFO (("swf STOP \n"));
break;
......
......@@ -141,7 +141,7 @@ bool BranchingTerminator::is_marked (const Edge& edge) const
if (!is_present) { return false; }
int extension_nucleotide_marked;
int extension_nucleotide_marked = 0;
int delta = getDelta (edge);
if (delta >= 0)
......@@ -168,7 +168,7 @@ void BranchingTerminator::mark (const Node& node)
// if it is a branching kmer, mark it directly (it may have no branching neighbor)
if (is_indexed(node))
{
Value val;
Value val = 0;
branching_kmers.get (node.kmer, val);
branching_kmers.set (node.kmer, val|(1<<8));
could_mark = true;
......@@ -233,7 +233,7 @@ bool BranchingTerminator::is_marked (const Node& node) const
*********************************************************************/
bool BranchingTerminator::is_marked_branching (const Node& node) const
{
Value val;
Value val = 0;
branching_kmers.get (node.kmer, val);
return (val&(1<<8)) != 0;
}
......
......@@ -98,7 +98,8 @@ Traversal::Traversal (
int max_depth,
int max_breadth
)
: graph(graph), terminator(terminator), stats(TraversalStats()), final_stats(TraversalStats()),
: final_stats(TraversalStats()), stats(TraversalStats()),
graph(graph), terminator(terminator),
maxlen (max_len == 0 ? Traversal::defaultMaxLen : max_len),
max_depth (max_depth == 0 ? Traversal::defaultMaxDepth : max_depth),
max_breadth (max_breadth == 0 ? Traversal::defaultMaxBreadth : max_breadth)
......@@ -124,7 +125,7 @@ int Traversal::traverse (const Node& startingNode, Node& currentNode, Direction
Path path; path.resize (max_depth+1);
int bubble_start, bubble_end;
int bubble_start=0, bubble_end=0;
bubbles_positions.clear();
/** We reset the consensus to be filled. */
......@@ -167,7 +168,7 @@ int Traversal::traverse (const Node& startingNode, Node& currentNode, Direction
if (looping) { break; }
if (consensus.size() > maxlen) { break; }
if ((int)consensus.size() > maxlen) { break; }
} /* end of while( (nnt = avance ... */
......@@ -468,14 +469,14 @@ int MonumentTraversal::find_end_of_branching (
}
// don't allow a depth too large
if (frontline.depth() > max_depth)
if ((int)frontline.depth() > max_depth)
{
stats.couldnt_traverse_bubble_depth++;
return 0;
}
// don't allow a breadth too large
if (frontline.size()> max_breadth)
if ((int)frontline.size()> max_breadth)
{
stats.couldnt_traverse_bubble_breadth++;
return 0;
......@@ -666,7 +667,7 @@ bool MonumentTraversal::validate_consensuses (set<Path>& consensuses, Path& resu
return false;
// don't traverse large deadends (here, having one consensus means the other paths were large deadends)
if (consensuses.size() == 1 && mean > graph.getKmerSize()+1) // deadend length should be < k+1 (most have length 1, but have seen up to 10 in ecoli)
if (consensuses.size() == 1 && mean > (int)graph.getKmerSize()+1) // deadend length should be < k+1 (most have length 1, but have seen up to 10 in ecoli)
return false;
if (debug) printf("%lu-bubble mean %d, stdev %.1f\n",consensuses.size(),mean,stdev);
......@@ -731,7 +732,6 @@ bool MonumentTraversal::all_consensuses_almost_identical (set<Path>& consensuses
*********************************************************************/
Path MonumentTraversal::most_abundant_consensus(set<Path>& consensuses)
{
int k = graph.getKmerSize();
Path res;
bool debug = false;
......@@ -744,7 +744,7 @@ Path MonumentTraversal::most_abundant_consensus(set<Path>& consensuses)
// naive conversion from path to string
string p_str = graph.toString(p.start);
for (int i = 0; i < p.size(); i++)
for (size_t i = 0; i < p.size(); i++)
p_str.push_back(p.ascii(i));
long mean_abundance = 0;
......
......@@ -91,7 +91,7 @@ public:
size_t nbCores = 0,
int min_abundance =0
)
: _bloomSize (bloomSize), _nbHash (nbHash), _nbCores(nbCores), _bloomKind(bloomKind), _min_abundance(min_abundance), _ksize(ksize)
: _bloomSize (bloomSize), _nbHash (nbHash), _nbCores(nbCores), _ksize(ksize), _min_abundance(min_abundance), _bloomKind(bloomKind)
{
}
......@@ -174,7 +174,7 @@ private:
class BuildKmerBloom
{
public:
void operator() (const Count& kmer) { if(kmer.abundance >= _min_abundance) _bloom.insert(kmer.value); }
void operator() (const Count& kmer) { if ((int)kmer.abundance >= _min_abundance) _bloom.insert(kmer.value); }
BuildKmerBloom (tools::collections::impl::IBloom<Type>& bloom, int min_abundance=0) : _bloom(bloom),_min_abundance(min_abundance) {}
tools::collections::impl::IBloom<Type>& _bloom;
int _min_abundance;
......
......@@ -111,10 +111,10 @@ DebloomAlgorithm<span>::DebloomAlgorithm (
_kmerSize(kmerSize),
_bloomKind(bloomKind), _debloomKind(cascadingKind),
_max_memory(max_memory),
_solidIterable(0), _container(0), _criticalNb(0)
_criticalNb(0), _solidIterable(0), _container(0)
{
/** We get a group for deblooming. */
Group& group = _storage().getGroup ("debloom");
_storage().getGroup ("debloom");
setSolidIterable (solidIterable);
......@@ -144,7 +144,7 @@ DebloomAlgorithm<span>::DebloomAlgorithm (tools::storage::impl::Storage& storage
_kmerSize(0),
_debloomUri("debloom"),
_max_memory(0),
_solidIterable(0), _container(0), _criticalNb(0)
_criticalNb(0), _solidIterable(0), _container(0)
{
/** We retrieve the cascading kind from the storage. */
parse (_groupDebloom.getProperty("kind"), _debloomKind);
......@@ -192,7 +192,7 @@ struct FunctorKmersExtension
Model& model;
FunctorKmersExtension (Model& model, IBloom<Type>* bloom, ThreadObject<BagCache<Type> >& extendBag)
: model(model), functorNeighbors(bloom,extendBag) {}
: functorNeighbors(bloom,extendBag), model(model) {}
void operator() (const Count& kmer) const
{
/** We iterate the neighbors of the current solid kmer. */
......
......@@ -160,7 +160,7 @@ struct FunctorKmersExtension
vector<Type>& solids,
Repartitor& repart
)
: model(model), bloom(bloom), functorNeighbors(bloom,modelMini, solids, extentParts, repart) {}
: functorNeighbors(bloom,modelMini, solids, extentParts, repart), model(model), bloom(bloom) {}
void operator() (const Count& kmer) const
{
......
......@@ -88,7 +88,7 @@ MPHFAlgorithm<span,Abundance_t>::MPHFAlgorithm (
IProperties* options
)
: Algorithm("emphf", 1, options), _group(group), _name(name), _buildOrLoad(buildOrLoad),
_solidCounts(0), _solidKmers(0), _map(0), _dataSize(0), _nb_abundances_above_precision(0), _progress(0)
_dataSize(0), _nb_abundances_above_precision(0), _solidCounts(0), _solidKmers(0), _map(0), _progress(0)
{
/** We keep a reference on the solid kmers. */
setSolidCounts (solidCounts);
......@@ -147,8 +147,6 @@ void MPHFAlgorithm<span,Abundance_t>::execute ()
/** We check whether we can use such a type. */
if (Map::enabled == true && _buildOrLoad == true)
{
size_t dataSize=0;
/** We need a progress object. */
tools::dp::IteratorListener* delegate = createIteratorListener(0,""); LOCAL (delegate);
setProgress (new ProgressCustom(delegate));
......
......@@ -27,10 +27,10 @@ namespace gatb { namespace core { namespace kmer { namespace impl {
// since we didn't define the functions in a .h file, that trick removes linker errors,
// see http://www.parashift.com/c++-faq-lite/separate-template-class-defn-from-decl.html
template class Kmer <KSIZE_1>;
template class Kmer <KSIZE_2>;
template class Kmer <KSIZE_3>;
template class Kmer <KSIZE_4>;
template struct Kmer <KSIZE_1>;
template struct Kmer <KSIZE_2>;
template struct Kmer <KSIZE_3>;
template struct Kmer <KSIZE_4>;
/********************************************************************************/
} } } } /* end of namespaces. */
......