MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / getRandomExclude

Function getRandomExclude

cdb2api/cdb2api.c:2689–2700  ·  view source on GitHub ↗

Get random value from range 0 to max-1 excluding 1 value */

Source from the content-addressed store, hash-verified

2687
2688/* Get random value from range 0 to max-1 excluding 1 value */
2689static int getRandomExclude(int max, int exclude)
2690{
2691 int val = 0;
2692 if (max < 2)
2693 return 0;
2694 for (int i = 0; i < 10; i++) {
2695 val = cdb2_random_int() % max;
2696 if (val != exclude)
2697 return val;
2698 }
2699 return val;
2700}
2701
2702static int cdb2_connect_sqlhost(cdb2_hndl_tp *hndl)
2703{

Callers 1

cdb2_connect_sqlhostFunction · 0.85

Calls 1

cdb2_random_intFunction · 0.85

Tested by

no test coverage detected