| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/sqlite/src/src/random.c | 
| Switch to Source code | Preprocessed file | 
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||
| 2 | - | |||||||||||||
| 3 | - | |||||||||||||
| 4 | - | |||||||||||||
| 5 | - | |||||||||||||
| 6 | static struct sqlite3PrngType { | - | ||||||||||||
| 7 | unsigned char isInit; | - | ||||||||||||
| 8 | unsigned char i, j; | - | ||||||||||||
| 9 | unsigned char s[256]; | - | ||||||||||||
| 10 | } sqlite3Prng; | - | ||||||||||||
| 11 | - | |||||||||||||
| 12 | - | |||||||||||||
| 13 | - | |||||||||||||
| 14 | - | |||||||||||||
| 15 | void sqlite3_randomness(int N, void *pBuf){ | - | ||||||||||||
| 16 | unsigned char t; | - | ||||||||||||
| 17 | unsigned char *zBuf = pBuf; | - | ||||||||||||
| 18 | sqlite3_mutex *mutex; | - | ||||||||||||
| 19 | - | |||||||||||||
| 20 | - | |||||||||||||
| 21 | - | |||||||||||||
| 22 | if( sqlite3_initialize() 
 never executed:  return; | 0-2368905 | ||||||||||||
| 23 | - | |||||||||||||
| 24 | - | |||||||||||||
| 25 | - | |||||||||||||
| 26 | mutex = sqlite3MutexAlloc(5); | - | ||||||||||||
| 27 | - | |||||||||||||
| 28 | - | |||||||||||||
| 29 | sqlite3_mutex_enter(mutex); | - | ||||||||||||
| 30 | if( N<=0 
 
 | 0-2367489 | ||||||||||||
| 31 | sqlite3Prng.isInit = 0; | - | ||||||||||||
| 32 | sqlite3_mutex_leave(mutex); | - | ||||||||||||
| 33 | return; executed 1416 times by 438 tests:  return;Executed by: 
 | 1416 | ||||||||||||
| 34 | } | - | ||||||||||||
| 35 | if( !sqlite3Prng.isInit 
 | 1074-2366415 | ||||||||||||
| 36 | int i; | - | ||||||||||||
| 37 | char k[256]; | - | ||||||||||||
| 38 | sqlite3Prng.j = 0; | - | ||||||||||||
| 39 | sqlite3Prng.i = 0; | - | ||||||||||||
| 40 | sqlite3OsRandomness(sqlite3_vfs_find(0), 256, k); | - | ||||||||||||
| 41 | for(i=0; i<256 
 | 1074-274944 | ||||||||||||
| 42 | sqlite3Prng.s[i] = (u8)i; | - | ||||||||||||
| 43 | } executed 274944 times by 396 tests:  end of blockExecuted by: 
 | 274944 | ||||||||||||
| 44 | for(i=0; i<256 
 | 1074-274944 | ||||||||||||
| 45 | sqlite3Prng.j += sqlite3Prng.s[i] + k[i]; | - | ||||||||||||
| 46 | t = sqlite3Prng.s[sqlite3Prng.j]; | - | ||||||||||||
| 47 | sqlite3Prng.s[sqlite3Prng.j] = sqlite3Prng.s[i]; | - | ||||||||||||
| 48 | sqlite3Prng.s[i] = t; | - | ||||||||||||
| 49 | } executed 274944 times by 396 tests:  end of blockExecuted by: 
 | 274944 | ||||||||||||
| 50 | sqlite3Prng.isInit = 1; | - | ||||||||||||
| 51 | } executed 1074 times by 396 tests:  end of blockExecuted by: 
 | 1074 | ||||||||||||
| 52 | - | |||||||||||||
| 53 | - | |||||||||||||
| 54 | ((void) (0)) | - | ||||||||||||
| 55 | ; | - | ||||||||||||
| 56 | do{ | - | ||||||||||||
| 57 | sqlite3Prng.i++; | - | ||||||||||||
| 58 | t = sqlite3Prng.s[sqlite3Prng.i]; | - | ||||||||||||
| 59 | sqlite3Prng.j += t; | - | ||||||||||||
| 60 | sqlite3Prng.s[sqlite3Prng.i] = sqlite3Prng.s[sqlite3Prng.j]; | - | ||||||||||||
| 61 | sqlite3Prng.s[sqlite3Prng.j] = t; | - | ||||||||||||
| 62 | t += sqlite3Prng.s[sqlite3Prng.i]; | - | ||||||||||||
| 63 | *(zBuf++) = sqlite3Prng.s[t]; | - | ||||||||||||
| 64 | } executed 288366033 times by 396 tests: while( -- end of blockExecuted by: 
 
 
 | 2367489-288366033 | ||||||||||||
| 65 | sqlite3_mutex_leave(mutex); | - | ||||||||||||
| 66 | } executed 2367489 times by 396 tests:  end of blockExecuted by: 
 | 2367489 | ||||||||||||
| 67 | static struct sqlite3PrngType sqlite3SavedPrng; | - | ||||||||||||
| 68 | void sqlite3PrngSaveState(void){ | - | ||||||||||||
| 69 | memcpy( | - | ||||||||||||
| 70 | &sqlite3SavedPrng, | - | ||||||||||||
| 71 | &sqlite3Prng, | - | ||||||||||||
| 72 | sizeof(sqlite3Prng) | - | ||||||||||||
| 73 | ); | - | ||||||||||||
| 74 | } executed 5 times by 1 test:  end of blockExecuted by: 
 | 5 | ||||||||||||
| 75 | void sqlite3PrngRestoreState(void){ | - | ||||||||||||
| 76 | memcpy( | - | ||||||||||||
| 77 | &sqlite3Prng, | - | ||||||||||||
| 78 | &sqlite3SavedPrng, | - | ||||||||||||
| 79 | sizeof(sqlite3Prng) | - | ||||||||||||
| 80 | ); | - | ||||||||||||
| 81 | } executed 927 times by 1 test:  end of blockExecuted by: 
 | 927 | ||||||||||||
| Switch to Source code | Preprocessed file |