LCOV - code coverage report
Current view: top level - src/server/protocol1 - blocklen.c (source / functions) Hit Total Coverage
Test: burp-coverage-clean.info Lines: 8 8 100.0 %
Date: 2016-05-01 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #include "../../burp.h"
       2             : #include "../backup_phase1.h"
       3             : 
       4             : #include <math.h>
       5             : 
       6             : // Use the same MAX_BLOCK_SIZE as rsync.
       7             : #define MAX_BLOCK_SIZE ((uint32_t)1 << 17)
       8             : 
       9             : /* Need to base librsync block length on the size of the old file, otherwise
      10             :    the risk of librsync collisions and silent corruption increases as the
      11             :    size of the new file gets bigger. */
      12          16 : size_t get_librsync_block_len(const char *endfile)
      13             : {
      14          16 :         size_t ret=0;
      15          16 :         uint64_t oldlen=0;
      16          16 :         oldlen=strtoull(endfile, NULL, 10);
      17             :         // round to a multiple of 16.
      18          16 :         ret=(size_t)(ceil((sqrt((double)oldlen))/16)*16);
      19          16 :         if(ret<64) return 64; // minimum of 64 bytes.
      20          13 :         if(ret>MAX_BLOCK_SIZE) return MAX_BLOCK_SIZE;
      21           9 :         return ret;
      22             : }

Generated by: LCOV version 1.10