Fix potential return value discrepancy when writing to urandom

This commit is contained in:
zhao maosheng 2024-07-15 17:29:11 +08:00 committed by Rbb666
parent 861e32490f
commit 393a61b048
1 changed files with 2 additions and 2 deletions

View File

@ -46,7 +46,7 @@ static rt_ssize_t random_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_si
static rt_ssize_t random_write(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size)
{
ssize_t ret = sizeof(seed);
ssize_t ret = sizeof(seed) < size ? sizeof(seed) : size;
rt_memcpy(&seed, buffer, ret);
return ret;
}
@ -137,7 +137,7 @@ static rt_ssize_t random_uread(rt_device_t dev, rt_off_t pos, void *buffer, rt_s
static rt_ssize_t random_uwrite(rt_device_t dev, rt_off_t pos, const void *buffer, rt_size_t size)
{
ssize_t ret = sizeof(useed);
ssize_t ret = sizeof(useed) < size ? sizeof(useed) : size;
rt_memcpy(&useed, buffer, ret);
return ret;
}