From a52b40384eb58fc2d7c06c7d46d1c401cde19443 Mon Sep 17 00:00:00 2001 From: Nick Bowler Date: Thu, 30 Jan 2014 22:32:28 -0500 Subject: [PATCH] liblbx: Remove use of SEEK_CUR in the image reader. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Other than this one seek, all other seeks used by the library are of the SEEK_SET type. Only requiring SEEK_SET will simplify implementations of lbx_file_ops quite a lot, so let's get rid of this one. The whole point of this seek is to skip just one byte — a normal read works just as well. --- src/image.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/image.c b/src/image.c index adc6a43..bd207e7 100644 --- a/src/image.c +++ b/src/image.c @@ -313,11 +313,14 @@ long lbx_img_read_row_data(struct lbx_image *pub, void *buf) return -1; } - if (!(img->flags & FLAG_RAW)) { - /* Skip padding byte, if any */ - if (img->currentn % 2) { - if (img->fops->seek(img->f, 1, SEEK_CUR)) - return -1; + if (!(img->flags & FLAG_RAW) && img->currentn % 2) { + unsigned char c; + + /* Skip padding byte */ + if (img->fops->read(&c, 1, img->f) != 1) { + if (img->fops->eof(img->f)) + lbx_error_raise(LBX_EEOF); + return -1; } } -- 2.43.0