提交 4f6973d6 编写于 作者: H Hui Li

[modify for coverity scan]

上级 89aa04de
......@@ -40,10 +40,17 @@ int taosRand(void)
unsigned long seed;
fd = open("/dev/urandom", 0);
if ((fd < 0) || (read(fd, &seed, sizeof(seed)) < 0)) seed = time(0);
if (fd >= 0) close(fd);
if (fd < 0) {
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();
}
#endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册