From: Nick Bowler Date: Fri, 31 Jan 2014 03:32:28 +0000 (-0500) Subject: liblbx: Remove use of SEEK_CUR in the image reader. X-Git-Url: https://git.draconx.ca/gitweb/liblbx.git/commitdiff_plain/a52b40384eb58fc2d7c06c7d46d1c401cde19443 liblbx: Remove use of SEEK_CUR in the image reader. 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. --- 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; } }