diff options
| author | Mattias Andrée <maandree@kth.se> | 2017-05-16 20:14:22 +0200 |
|---|---|---|
| committer | Mattias Andrée <maandree@kth.se> | 2017-05-16 20:14:22 +0200 |
| commit | 0f03cc378e6ce48f17a20e409f93bfc11345a6ed (patch) | |
| tree | f4768c6fe96e1ac2a9c5833dee897924300d4a45 /src/blind-reverse.c | |
| parent | Add blind-tempral-mean (diff) | |
| download | blind-0f03cc378e6ce48f17a20e409f93bfc11345a6ed.tar.gz blind-0f03cc378e6ce48f17a20e409f93bfc11345a6ed.tar.bz2 blind-0f03cc378e6ce48f17a20e409f93bfc11345a6ed.tar.xz | |
Fix errors and warnings and make the code cleaner
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'src/blind-reverse.c')
| -rw-r--r-- | src/blind-reverse.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/blind-reverse.c b/src/blind-reverse.c index 7d3e504..0851f1f 100644 --- a/src/blind-reverse.c +++ b/src/blind-reverse.c @@ -1,6 +1,5 @@ /* See LICENSE file for copyright and license details. */ -#include "stream.h" -#include "util.h" +#include "common.h" USAGE("[-i] file") @@ -9,15 +8,15 @@ to_stdout(struct stream *stream) { size_t ptr, end, n; char buf[BUFSIZ]; - ssize_t r; while (stream->frames--) { ptr = stream->frames * stream->frame_size + stream->headlen; end = ptr + stream->frame_size; while (ptr < end) { - if (!(r = epread(stream->fd, buf, MIN(sizeof(buf), end - ptr), ptr, stream->file))) + if (!(n = epread(stream->fd, buf, MIN(sizeof(buf), end - ptr), + (off_t)ptr, stream->file))) eprintf("%s: file is shorter than expected\n", stream->file); - ptr += n = (size_t)r; + ptr += n; ewriteall(STDOUT_FILENO, buf, n, "<stdout>"); } } @@ -57,8 +56,8 @@ in_place(struct stream *stream) bufb = emalloc(stream->frame_size); for (f = 0; f < stream->frames >> 1; f++) { - pa = f * stream->frame_size + stream->headlen; - pb = (fm - f) * stream->frame_size + stream->headlen; + pa = (off_t)f * (off_t)(stream->frame_size) + (off_t)(stream->headlen); + pb = (off_t)(fm - f) * (off_t)(stream->frame_size) + (off_t)(stream->headlen); epread_frame(stream, bufa, pa); epread_frame(stream, bufb, pb); |
