]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Avoid some casts by changing the private API (#2578)
authorGraham Percival <gperciva@tarsnap.com>
Sat, 12 Apr 2025 20:58:03 +0000 (13:58 -0700)
committerGitHub <noreply@github.com>
Sat, 12 Apr 2025 20:58:03 +0000 (13:58 -0700)
libarchive/archive_options.c
libarchive/archive_options_private.h
libarchive/archive_read_disk_posix.c
libarchive/archive_read_disk_private.h
libarchive/archive_read_disk_windows.c
libarchive/archive_write_set_format_7zip.c
libarchive/archive_write_set_format_gnutar.c

index 92647c9b41c117fc203e1a8f04161e7e0f5190ff..6e2c0d2a5971f16be0e0ab03c8b757677a3940b7 100644 (file)
@@ -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;
index 3e49222dabdf47f963129e4d1c17db2fc968b043..f07d242ee65b4479afc503ab58bd9dc40cfd529a 100644 (file)
@@ -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,
index 4839d62b291d39a1897495141ce84e04376d2184..a7a98e9cb1cd1152aac93a4506cf7928beb39f92 100644 (file)
@@ -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;
 
index cf8da99a029b3efc3498b0a444bb3588e72eff58..891ffd437ed57098a45a83d410055a38130a9881 100644 (file)
@@ -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;
index 9d6aec9a1d74c8d2704138863fa9dce957f309b7..a774305d0cf21dfe6b4ef4009fd204489b3cf79d 100644 (file)
@@ -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;
index 8568b37e21b6f99342cd7735fbd10649521ba1b8..e7644c03d5da5dd0be231f98f10eb1fc4b3391ef 100644 (file)
@@ -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;
index 04b190de4402ece5d60cf6c37190d5307edcdf4b..ec1e1d342feab2ffdca2418ca4fd9f20de299154 100644 (file)
@@ -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;