summaryrefslogtreecommitdiff
path: root/libarchive/archive_read_support_filter_uu.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_uu.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_uu.c')
-rw-r--r--libarchive/archive_read_support_filter_uu.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/libarchive/archive_read_support_filter_uu.c b/libarchive/archive_read_support_filter_uu.c
index 46dcc037..7a6da6a1 100644
--- a/libarchive/archive_read_support_filter_uu.c
+++ b/libarchive/archive_read_support_filter_uu.c
@@ -86,18 +86,9 @@ int
archive_read_support_filter_uu(struct archive *_a)
{
struct archive_read *a = (struct archive_read *)_a;
- struct archive_read_filter_bidder *bidder;
- archive_check_magic(_a, ARCHIVE_READ_MAGIC,
- ARCHIVE_STATE_NEW, "archive_read_support_filter_uu");
-
- if (__archive_read_get_bidder(a, &bidder) != ARCHIVE_OK)
- return (ARCHIVE_FATAL);
-
- bidder->data = NULL;
- bidder->name = "uu";
- bidder->vtable = &uudecode_bidder_vtable;
- return (ARCHIVE_OK);
+ return __archive_read_register_bidder(a, NULL, "uu",
+ &uudecode_bidder_vtable);
}
static const unsigned char ascii[256] = {