From: Emil Velikov Date: Mon, 30 Mar 2020 21:54:21 +0000 (+0100) Subject: reader: track read_filter "can_seek" with a flag X-Git-Tag: v3.6.0~18^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4e7a6bd81187629e6f99ef8c5456a96c93be3d94;p=thirdparty%2Flibarchive.git reader: track read_filter "can_seek" with a flag Currently we the ::seek callback can be either NULL or client_seek_proxy. Since we already explicitly use the latter, instead of ::seek just drop the function pointer all together, in favour of a simple flag. Alternatively one could use a ARCHIVE_FILTER_NONE check. Signed-off-by: Emil Velikov --- diff --git a/libarchive/archive_read.c b/libarchive/archive_read.c index 235260579..0a749c81d 100644 --- a/libarchive/archive_read.c +++ b/libarchive/archive_read.c @@ -489,11 +489,11 @@ archive_read_open1(struct archive *_a) filter->open = client_open_proxy; filter->read = client_read_proxy; filter->skip = client_skip_proxy; - filter->seek = client_seek_proxy; filter->close = client_close_proxy; filter->sswitch = client_switch_proxy; filter->name = "none"; filter->code = ARCHIVE_FILTER_NONE; + filter->can_seek = 1; a->client.dataset[0].begin_position = 0; if (!a->filter || !a->bypass_filter_bidding) @@ -1633,7 +1633,7 @@ __archive_read_filter_seek(struct archive_read_filter *filter, int64_t offset, if (filter->closed || filter->fatal) return (ARCHIVE_FATAL); - if (filter->seek == NULL) + if (filter->can_seek == 0) return (ARCHIVE_FAILED); client = &(filter->archive->client); diff --git a/libarchive/archive_read_private.h b/libarchive/archive_read_private.h index ff6c336c9..b55595669 100644 --- a/libarchive/archive_read_private.h +++ b/libarchive/archive_read_private.h @@ -93,8 +93,6 @@ struct archive_read_filter { ssize_t (*read)(struct archive_read_filter *, const void **); /* Skip forward this many bytes. */ int64_t (*skip)(struct archive_read_filter *self, int64_t request); - /* Seek to an absolute location. */ - int64_t (*seek)(struct archive_read_filter *self, int64_t offset, int whence); /* Close (just this filter) and free(self). */ int (*close)(struct archive_read_filter *self); /* Function that handles switching from reading one block to the next/prev */ @@ -106,6 +104,7 @@ struct archive_read_filter { const char *name; int code; + int can_seek; /* Used by reblocking logic. */ char *buffer;