Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CID 1077117 (Medium): Division or modulo by zero (DIVIDE_BY_ZERO) #182

Closed
mr-c opened this issue Oct 16, 2013 · 1 comment
Closed

CID 1077117 (Medium): Division or modulo by zero (DIVIDE_BY_ZERO) #182

mr-c opened this issue Oct 16, 2013 · 1 comment
Labels
Milestone

Comments

@mr-c
Copy link
Contributor

mr-c commented Oct 16, 2013

from lib/hashbits.cc

1902 //
1903 // consume_fasta: consume a FASTA file of reads
1904 //
1905
1906 void Hashbits::consume_fasta_overlap(const std::string &filename,
1907                              HashIntoType curve[2][100],Hashbits &ht2,
1908                              unsigned int &total_reads,
1909                              unsigned long long &n_consumed,
1910                              CallbackFn callback,
1911                              void * callback_data)
1912 {
        1. assignment: Assigning: "total_reads" = "0U".
1913  total_reads = 0;
1914  n_consumed = 0;
1915  Read read;
1916
1917 //get total number of reads in dataset
1918
1919  IParser* parser = IParser::get_parser(filename.c_str());
        2. Condition "!parser->is_complete()", taking true branch
        5. Condition "!parser->is_complete()", taking false branch
1920  while(!parser->is_complete())  {
1921    read = parser->get_next_read();
        3. incr: Incrementing "total_reads". The value of "total_reads" is now 1.
1922    total_reads++;
        4. Jumping back to the beginning of the loop
1923  }
1924 //block size for curve
        6. assignment: Assigning: "block_size" = "total_reads / 100U". The value of "block_size" is now 0.
1925  int block_size = total_reads/100;
1926  
1927  total_reads = 0;
1928  khmer::HashIntoType start = 0, stop = 0;
1929  
1930  delete parser;
1931  parser = IParser::get_parser(filename.c_str());
1932
1933
1934
1935  string currName = "";
1936  string currSeq = "";
1937
1938  //
1939  // iterate through the FASTA file & consume the reads.
1940  //
1941
        7. Condition "!parser->is_complete()", taking true branch
1942  while(!parser->is_complete())  {
1943    read = parser->get_next_read();
1944    currSeq = read.sequence;
1945    currName = read.name; 
1946
1947      unsigned int this_n_consumed;
1948      bool is_valid;
1949
1950      this_n_consumed = check_and_process_read_overlap(currSeq,
1951                                               is_valid, ht2);
1952
1953        n_consumed += this_n_consumed;
1954               
1955    // reset the sequence info, increment read number
1956
1957    total_reads++;
1958

CID 1077117 (#1 of 1): Division or modulo by zero (DIVIDE_BY_ZERO)
8. divide_by_zero: In expression "total_reads % block_size" modulo by expression "block_size" which may be zero has undefined behavior.
1959    if (total_reads%block_size == 0) {
1960        curve[0][total_reads/block_size-1] = n_overlap_kmers(start,stop);
1961        curve[1][total_reads/block_size-1] = n_kmers(start,stop);
1962    }
1963    // run callback, if specified
1964    if (total_reads % CALLBACK_PERIOD == 0 && callback) {
1965      try {
1966        callback("consume_fasta", callback_data, total_reads, n_consumed);
1967      } catch (...) {
1968        throw;
1969      }
1970    }
1971
1972  } // while
1973  
1974  delete parser;
1975 }
@mr-c
Copy link
Contributor Author

mr-c commented Feb 3, 2014

@luizirber Did you write up a fix for this? If not I will do so.

qingpeng pushed a commit that referenced this issue Mar 26, 2014
… by #182

2. add test code for count-overlap.py
3. fix count-overlap.py (a character was removed accidently some time and hashsize was replaced by min_hashsize)
4. count-overlap.py needs hashbits table generated by load-graph.py. This information is added to the "usage:" line.
@mr-c mr-c closed this as completed Mar 31, 2014
qingpeng pushed a commit that referenced this issue Apr 1, 2014
… by #182

2. add test code for count-overlap.py
3. fix count-overlap.py (a character was removed accidently some time and hashsize was replaced by min_hashsize)
4. count-overlap.py needs hashbits table generated by load-graph.py. This information is added to the "usage:" line.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant