1
0
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:
Pavol Rusnak 2014-07-17 16:37:42 +02:00
commit 8f38acd48f
3 changed files with 10 additions and 4 deletions

2
.gitignore vendored
View File

@ -1,3 +1,5 @@
*.o
*.exe
*~
test-openssl
tests

10
rand.c
View File

@ -22,6 +22,7 @@
*/
#include <stdio.h>
#include <assert.h>
#include "rand.h"
@ -35,11 +36,14 @@ void init_rand(void)
uint32_t random32(void)
{
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;
}
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);
}

2
rand.h
View File

@ -28,6 +28,6 @@
void init_rand(void);
uint32_t random32(void);
void random_buffer(uint8_t *buf, uint32_t len);
void random_buffer(uint8_t *buf, size_t len);
#endif