From: Graham Percival Date: Sat, 12 Apr 2025 20:58:03 +0000 (-0700) Subject: Avoid some casts by changing the private API (#2578) X-Git-Tag: v3.8.0~44 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=8f49a18f64b42651fac9e7b210a779c076184c53;p=thirdparty%2Flibarchive.git Avoid some casts by changing the private API (#2578) --- diff --git a/libarchive/archive_options.c b/libarchive/archive_options.c index 92647c9b4..6e2c0d2a5 100644 --- a/libarchive/archive_options.c +++ b/libarchive/archive_options.c @@ -38,7 +38,7 @@ parse_option(const char **str, int _archive_set_option(struct archive *a, const char *m, const char *o, const char *v, - int magic, const char *fn, option_handler use_option) + unsigned int magic, const char *fn, option_handler use_option) { const char *mp, *op, *vp; int r; @@ -97,7 +97,7 @@ _archive_set_either_option(struct archive *a, const char *m, const char *o, cons int _archive_set_options(struct archive *a, const char *options, - int magic, const char *fn, option_handler use_option) + unsigned int magic, const char *fn, option_handler use_option) { int allok = 1, anyok = 0, ignore_mod_err = 0, r; char *data; diff --git a/libarchive/archive_options_private.h b/libarchive/archive_options_private.h index 3e49222da..f07d242ee 100644 --- a/libarchive/archive_options_private.h +++ b/libarchive/archive_options_private.h @@ -35,11 +35,11 @@ typedef int (*option_handler)(struct archive *a, int _archive_set_option(struct archive *a, const char *mod, const char *opt, const char *val, - int magic, const char *fn, option_handler use_option); + unsigned int magic, const char *fn, option_handler use_option); int _archive_set_options(struct archive *a, const char *options, - int magic, const char *fn, option_handler use_option); + unsigned int magic, const char *fn, option_handler use_option); int _archive_set_either_option(struct archive *a, diff --git a/libarchive/archive_read_disk_posix.c b/libarchive/archive_read_disk_posix.c index 4839d62b2..a7a98e9cb 100644 --- a/libarchive/archive_read_disk_posix.c +++ b/libarchive/archive_read_disk_posix.c @@ -276,7 +276,7 @@ tree_dir_next_posix(struct tree *t); #endif /* Initiate/terminate a tree traversal. */ -static struct tree *tree_open(const char *, int, int); +static struct tree *tree_open(const char *, char, int); static struct tree *tree_reopen(struct tree *, const char *, int); static void tree_close(struct tree *); static void tree_free(struct tree *); @@ -514,7 +514,7 @@ _archive_read_close(struct archive *_a) static void setup_symlink_mode(struct archive_read_disk *a, char symlink_mode, - int follow_symlinks) + char follow_symlinks) { a->symlink_mode = symlink_mode; a->follow_symlinks = follow_symlinks; @@ -2181,7 +2181,7 @@ tree_append(struct tree *t, const char *name, size_t name_length) * Open a directory tree for traversal. */ static struct tree * -tree_open(const char *path, int symlink_mode, int restore_time) +tree_open(const char *path, char symlink_mode, int restore_time) { struct tree *t; diff --git a/libarchive/archive_read_disk_private.h b/libarchive/archive_read_disk_private.h index cf8da99a0..891ffd437 100644 --- a/libarchive/archive_read_disk_private.h +++ b/libarchive/archive_read_disk_private.h @@ -52,10 +52,11 @@ struct archive_read_disk { /* * Since symlink interaction changes, we need to track whether - * we're following symlinks for the current item. 'L' mode above - * sets this true, 'P' sets it false, 'H' changes it as we traverse. + * we're following symlinks for the current item, governed by the above + * symlink_mode. 'L' sets this true, 'P' sets it false, 'H' changes it + * as we traverse. */ - char follow_symlinks; /* Either 'L' or 'P'. */ + char follow_symlinks; /* Either 0 or 1. */ /* Directory traversals. */ struct tree *tree; diff --git a/libarchive/archive_read_disk_windows.c b/libarchive/archive_read_disk_windows.c index 9d6aec9a1..a774305d0 100644 --- a/libarchive/archive_read_disk_windows.c +++ b/libarchive/archive_read_disk_windows.c @@ -603,7 +603,7 @@ _archive_read_close(struct archive *_a) static void setup_symlink_mode(struct archive_read_disk *a, char symlink_mode, - int follow_symlinks) + char follow_symlinks) { a->symlink_mode = symlink_mode; a->follow_symlinks = follow_symlinks; diff --git a/libarchive/archive_write_set_format_7zip.c b/libarchive/archive_write_set_format_7zip.c index 8568b37e2..e7644c03d 100644 --- a/libarchive/archive_write_set_format_7zip.c +++ b/libarchive/archive_write_set_format_7zip.c @@ -303,7 +303,7 @@ static int compression_code_lzma(struct archive *, static int compression_end_lzma(struct archive *, struct la_zstream *); #endif static int compression_init_encoder_ppmd(struct archive *, - struct la_zstream *, unsigned, uint32_t); + struct la_zstream *, uint8_t, uint32_t); static int compression_code_ppmd(struct archive *, struct la_zstream *, enum la_zaction); static int compression_end_ppmd(struct archive *, struct la_zstream *); @@ -2272,7 +2272,7 @@ ppmd_write(void *p, Byte b) static int compression_init_encoder_ppmd(struct archive *a, - struct la_zstream *lastrm, unsigned maxOrder, uint32_t msize) + struct la_zstream *lastrm, uint8_t maxOrder, uint32_t msize) { struct ppmd_stream *strm; uint8_t *props; diff --git a/libarchive/archive_write_set_format_gnutar.c b/libarchive/archive_write_set_format_gnutar.c index 04b190de4..ec1e1d342 100644 --- a/libarchive/archive_write_set_format_gnutar.c +++ b/libarchive/archive_write_set_format_gnutar.c @@ -153,7 +153,7 @@ static const char template_header[] = { static int archive_write_gnutar_options(struct archive_write *, const char *, const char *); static int archive_format_gnutar_header(struct archive_write *, char h[512], - struct archive_entry *, int tartype); + struct archive_entry *, char tartype); static int archive_write_gnutar_header(struct archive_write *, struct archive_entry *entry); static ssize_t archive_write_gnutar_data(struct archive_write *a, const void *buff, @@ -274,7 +274,7 @@ archive_write_gnutar_header(struct archive_write *a, { char buff[512]; int r, ret, ret2 = ARCHIVE_OK; - int tartype; + char tartype; struct gnutar *gnutar; struct archive_string_conv *sconv; struct archive_entry *entry_main; @@ -562,7 +562,7 @@ exit_write_header: static int archive_format_gnutar_header(struct archive_write *a, char h[512], - struct archive_entry *entry, int tartype) + struct archive_entry *entry, char tartype) { unsigned int checksum; int i, ret;