mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-24 07:09:48 +08:00
test time: Fixed bad assumption about RAND_MAX (#11414)
usleep range was up to 2147 Seconds
Per open group: The rand() function shall compute a
sequence of pseudo-random integers in the range
[0, {RAND_MAX}] with a period of at least 2^32
{RAND_MAX} Maximum value returned by rand();
at least 32767.
/* Maximum value returned by rand(). Must be a minimum of 32767. */
#define RAND_MAX INT_MAX
and
#define INT_MAX 2147483647
This commit is contained in:
committed by
Daniel Agar
parent
2217faf812
commit
c6edf41a74
@@ -104,7 +104,7 @@ int test_time(int argc, char *argv[])
|
||||
/* loop checking the time */
|
||||
for (unsigned i = 0; i < 100; i++) {
|
||||
|
||||
usleep(rand());
|
||||
usleep(rand() % SHRT_MAX);
|
||||
|
||||
uint32_t flags = px4_enter_critical_section();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user