[modify for coverity scan]
This commit is contained in:
parent
89aa04debb
commit
4f6973d6ec
|
@ -40,10 +40,17 @@ int taosRand(void)
|
||||||
unsigned long seed;
|
unsigned long seed;
|
||||||
|
|
||||||
fd = open("/dev/urandom", 0);
|
fd = open("/dev/urandom", 0);
|
||||||
if ((fd < 0) || (read(fd, &seed, sizeof(seed)) < 0)) seed = time(0);
|
if (fd < 0) {
|
||||||
if (fd >= 0) close(fd);
|
seed = time(0);
|
||||||
|
} else {
|
||||||
|
int len = read(fd, &seed, sizeof(seed));
|
||||||
|
if (len < 0) {
|
||||||
|
seed = time(0);
|
||||||
|
}
|
||||||
|
srand(seed);
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
srand(seed);
|
|
||||||
return rand();
|
return rand();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue