1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-27 23:41:18 +01:00

Merge pull request #18372 from benpicco/random_bytes-void

random: use void * in random_bytes()
This commit is contained in:
Marian Buschsieweke 2022-07-27 10:29:51 +02:00 committed by GitHub
commit e1ef2a0635
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -82,7 +82,7 @@ uint32_t random_uint32(void);
/**
* @brief writes random bytes in the [0,0xff]-interval to memory
*/
void random_bytes(uint8_t *buf, size_t size);
void random_bytes(void *buf, size_t size);
/**
* @brief generates a random number r with a <= r < b.

View File

@ -60,9 +60,10 @@ void auto_init_random(void)
random_init(seed);
}
void random_bytes(uint8_t *target, size_t n)
void random_bytes(void *target, size_t n)
{
uint32_t random;
uint8_t *dst = target;
uint8_t *random_pos = (uint8_t*)&random;
unsigned _n = 0;
@ -71,7 +72,7 @@ void random_bytes(uint8_t *target, size_t n)
random = random_uint32();
random_pos = (uint8_t *) &random;
}
*target++ = *random_pos++;
*dst++ = *random_pos++;
}
}