summaryrefslogtreecommitdiff
path: root/libarchive/archive_read_support_filter_lrzip.c
diff options
context:
space:
mode:
authorEmil Velikov <emil.l.velikov@gmail.com>2021-10-23 18:22:05 +0100
committerEmil Velikov <emil.l.velikov@gmail.com>2021-10-23 19:26:23 +0100
commit5b5f6b591bced6037959945f69ab46466abd1698 (patch)
tree0ca11fbd330c1fd1aa1a19daea93a50948fb2992 /libarchive/archive_read_support_filter_lrzip.c
parent64b82ac5c8cb5d822962af988dd075331d997b79 (diff)
downloadlibarchive-5b5f6b591bced6037959945f69ab46466abd1698.tar.gz
reader: transform get_bidder into register_bidder
There's a notable duplication across all the read bidder code. Check the archive magic/state, set the bidder private data (to NULL in all but one case), name and vtable. Change the helper to do the actual registration, keeping things simpler in the dozen+ filters. This also allows us to enforce the bidder ::bid and ::init dispatch are non NULL. The final one ::free is optional. NOTE: some of the bidders do _not_ set a name, which I suspect is a pre-existing bug. I've left them as-is, but we might want to fix and enforce that somehow. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Diffstat (limited to 'libarchive/archive_read_support_filter_lrzip.c')
-rw-r--r--libarchive/archive_read_support_filter_lrzip.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/libarchive/archive_read_support_filter_lrzip.c b/libarchive/archive_read_support_filter_lrzip.c
index 77dae4b3..a2389894 100644
--- a/libarchive/archive_read_support_filter_lrzip.c
+++ b/libarchive/archive_read_support_filter_lrzip.c
@@ -63,17 +63,11 @@ int
archive_read_support_filter_lrzip(struct archive *_a)
{
struct archive_read *a = (struct archive_read *)_a;
- struct archive_read_filter_bidder *reader;
- archive_check_magic(_a, ARCHIVE_READ_MAGIC,
- ARCHIVE_STATE_NEW, "archive_read_support_filter_lrzip");
-
- if (__archive_read_get_bidder(a, &reader) != ARCHIVE_OK)
+ if (__archive_read_register_bidder(a, NULL, "lrzip",
+ &lrzip_bidder_vtable) != ARCHIVE_OK)
return (ARCHIVE_FATAL);
- reader->data = NULL;
- reader->name = "lrzip";
- reader->vtable = &lrzip_bidder_vtable;
/* This filter always uses an external program. */
archive_set_error(_a, ARCHIVE_ERRNO_MISC,
"Using external lrzip program for lrzip decompression");