diff options
author | Mattias Andrée <maandree@kth.se> | 2019-02-11 17:56:37 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2019-02-11 17:56:37 +0100 |
commit | 5cee9b9c6394cffee6f31fab00323d9e559f0702 (patch) | |
tree | d21ba3da234c46b4f3c96e0065eb83d8c3cc8e96 /libkeccak_generalised_sum_fd.c | |
parent | Deprecate typedefs (diff) | |
download | libkeccak-5cee9b9c6394cffee6f31fab00323d9e559f0702.tar.gz libkeccak-5cee9b9c6394cffee6f31fab00323d9e559f0702.tar.bz2 libkeccak-5cee9b9c6394cffee6f31fab00323d9e559f0702.tar.xz |
General improvements
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'libkeccak_generalised_sum_fd.c')
-rw-r--r-- | libkeccak_generalised_sum_fd.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/libkeccak_generalised_sum_fd.c b/libkeccak_generalised_sum_fd.c index 634d2c2..7c4df54 100644 --- a/libkeccak_generalised_sum_fd.c +++ b/libkeccak_generalised_sum_fd.c @@ -21,26 +21,26 @@ libkeccak_generalised_sum_fd(int fd, struct libkeccak_state *restrict state, con ssize_t got; struct stat attr; size_t blksize = 4096; - char *restrict chunk; + void *restrict chunk; if (libkeccak_state_initialise(state, spec) < 0) return -1; if (fstat(fd, &attr) == 0) if (attr.st_blksize > 0) - blksize = (size_t)(attr.st_blksize); + blksize = (size_t)attr.st_blksize; chunk = alloca(blksize); for (;;) { got = read(fd, chunk, blksize); - if (got < 0) { + if (got <= 0) { + if (!got) + break; if (errno == EINTR) continue; return -1; } - if (got == 0) - break; if (libkeccak_fast_update(state, chunk, (size_t)got) < 0) return -1; } |