mirror of
https://github.com/espressif/openthread.git
synced 2026-09-09 02:30:11 +00:00
[random] assert aMax is bigger than aMin (#3894)
This commit is contained in:
@@ -36,10 +36,11 @@
|
||||
|
||||
#include "openthread-core-config.h"
|
||||
|
||||
#include "utils/wrap_stdint.h"
|
||||
|
||||
#include <openthread/error.h>
|
||||
|
||||
#include "common/debug.hpp"
|
||||
#include "utils/wrap_stdint.h"
|
||||
|
||||
#ifndef OPENTHREAD_RADIO
|
||||
|
||||
#include <mbedtls/ctr_drbg.h>
|
||||
@@ -90,6 +91,7 @@ inline uint16_t GetUint16(void)
|
||||
*/
|
||||
inline uint8_t GetUint8InRange(uint8_t aMin, uint8_t aMax)
|
||||
{
|
||||
assert(aMax > aMin);
|
||||
return (aMin + (GetUint8() % (aMax - aMin)));
|
||||
}
|
||||
|
||||
@@ -105,6 +107,7 @@ inline uint8_t GetUint8InRange(uint8_t aMin, uint8_t aMax)
|
||||
*/
|
||||
inline uint16_t GetUint16InRange(uint16_t aMin, uint16_t aMax)
|
||||
{
|
||||
assert(aMax > aMin);
|
||||
return (aMin + (GetUint16() % (aMax - aMin)));
|
||||
}
|
||||
|
||||
@@ -121,6 +124,7 @@ inline uint16_t GetUint16InRange(uint16_t aMin, uint16_t aMax)
|
||||
*/
|
||||
inline uint32_t GetUint32InRange(uint32_t aMin, uint32_t aMax)
|
||||
{
|
||||
assert(aMax > aMin);
|
||||
return (aMin + (GetUint32() % (aMax - aMin)));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user