From 0a7e36380717fe926d43ab30ef6162db9bd71723 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 4 Mar 2016 09:28:01 +0100 Subject: Add makefile and fix errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/zrand.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/zrand.c') diff --git a/src/zrand.c b/src/zrand.c index fa1bdfa..c5c8e8a 100644 --- a/src/zrand.c +++ b/src/zrand.c @@ -1,5 +1,5 @@ /* See LICENSE file for copyright and license details. */ -#include "internals" +#include "internals.h" #include #include @@ -27,12 +27,12 @@ zrand_get_random_bits(z_t r, size_t bits, int fd) read_just = read(fd, (char *)(r->chars) + read_total, n); if (read_just < 0) FAILURE_JUMP(); - read_total += read_just; - n -= read_just; + read_total += (size_t)read_just; + n -= (size_t)read_just; } - bit = BITS_IN_LAST_CHAR(bit) - mask <<= bit; + bits = BITS_IN_LAST_CHAR(bits); + mask <<= bits; mask -= 1; r->chars[chars - 1] &= mask; @@ -70,6 +70,8 @@ zrand(z_t r, enum zranddev dev, enum zranddist dist, z_t n) } fd = open(pathname, O_RDONLY); + if (fd < 0) + FAILURE_JUMP(); switch (dist) { case QUASIUNIFORM: -- cgit v1.2.3-70-g09d2