From aa1592ae2be143e1d14682e189637541eac7d9b1 Mon Sep 17 00:00:00 2001 From: Daniel Krebs Date: Mon, 26 Mar 2018 15:41:40 +0200 Subject: [PATCH] utils: read_random() now returns the number of bytes written --- fpga/include/villas/utils.h | 2 +- fpga/lib/utils.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fpga/include/villas/utils.h b/fpga/include/villas/utils.h index 272afd6eb..828796fb6 100644 --- a/fpga/include/villas/utils.h +++ b/fpga/include/villas/utils.h @@ -240,7 +240,7 @@ int version_parse(const char *s, struct version *v); #endif /** Fill buffer with random data */ -ssize_t read_random(char *buf, size_t len); +size_t read_random(char *buf, size_t len); /** Get CPU timestep counter */ __attribute__((always_inline)) static inline uint64_t rdtsc() diff --git a/fpga/lib/utils.c b/fpga/lib/utils.c index 2e295191d..10fc8348f 100644 --- a/fpga/lib/utils.c +++ b/fpga/lib/utils.c @@ -260,14 +260,14 @@ void * memdup(const void *src, size_t bytes) return dst; } -ssize_t read_random(char *buf, size_t len) +size_t read_random(char *buf, size_t len) { int fd; ssize_t bytes, total; fd = open("/dev/urandom", O_RDONLY); if (fd < 0) - return -1; + return 0; bytes = 0; total = 0;