mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-26 17:38:39 +00:00
Merge pull request #10 from dllaurence/fread-return
Test fread return value
This commit is contained in:
commit
8f38acd48f
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
|||||||
*.o
|
*.o
|
||||||
|
*.exe
|
||||||
|
*~
|
||||||
test-openssl
|
test-openssl
|
||||||
tests
|
tests
|
||||||
|
10
rand.c
10
rand.c
@ -22,6 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#include "rand.h"
|
#include "rand.h"
|
||||||
|
|
||||||
@ -35,11 +36,14 @@ void init_rand(void)
|
|||||||
uint32_t random32(void)
|
uint32_t random32(void)
|
||||||
{
|
{
|
||||||
uint32_t r;
|
uint32_t r;
|
||||||
fread(&r, 1, sizeof(r), f);
|
size_t len = sizeof(r);
|
||||||
|
size_t len_read = fread(&r, 1, len, f);
|
||||||
|
assert(len_read == len);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void random_buffer(uint8_t *buf, uint32_t len)
|
void random_buffer(uint8_t *buf, size_t len)
|
||||||
{
|
{
|
||||||
fread(buf, 1, len, f);
|
size_t len_read = fread(buf, 1, len, f);
|
||||||
|
assert(len_read == len);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user