]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Cast (mode_t)mode for POSIX functions (#2476)
authorGraham Percival <gperciva@tarsnap.com>
Tue, 7 Jan 2025 00:44:40 +0000 (16:44 -0800)
committerMartin Matuska <martin@matuska.de>
Tue, 11 Mar 2025 09:32:00 +0000 (10:32 +0100)
(cherry picked from commit 42565b88b5cc7441239269902a9d1735fd9ca0e2)

libarchive/archive_write_disk_posix.c
test_utils/test_main.c
unzip/bsdunzip.c

index 899f50f50ed47cb6fe89802a74b68dc3d1a9e10f..6b6ded739279bf39abbf5d73714f69da89af3552 100644 (file)
@@ -3788,7 +3788,7 @@ set_mode(struct archive_write_disk *a, int mode)
                 * permissions on symlinks, so a failure here has no
                 * impact.
                 */
-               if (lchmod(a->name, mode) != 0) {
+               if (lchmod(a->name, (mode_t)mode) != 0) {
                        switch (errno) {
                        case ENOTSUP:
                        case ENOSYS:
@@ -3818,12 +3818,12 @@ set_mode(struct archive_write_disk *a, int mode)
                 */
 #ifdef HAVE_FCHMOD
                if (a->fd >= 0)
-                       r2 = fchmod(a->fd, mode);
+                       r2 = fchmod(a->fd, (mode_t)mode);
                else
 #endif
                /* If this platform lacks fchmod(), then
                 * we'll just use chmod(). */
-               r2 = chmod(a->name, mode);
+               r2 = chmod(a->name, (mode_t)mode);
 
                if (r2 != 0) {
                        archive_set_error(&a->archive, errno,
index d2000432645e7e3199a5a30d393ee4c78548f324..80d969caf9bc713eecec3e4b6058ec8370545367 100644 (file)
@@ -611,7 +611,7 @@ int
 assertion_chmod(const char *file, int line, const char *pathname, int mode)
 {
        assertion_count(file, line);
-       if (chmod(pathname, mode) == 0)
+       if (chmod(pathname, (mode_t)mode) == 0)
                return (1);
        failure_start(file, line, "chmod(\"%s\", %4.o)", pathname,
            (unsigned int)mode);
@@ -1950,8 +1950,8 @@ assertion_make_dir(const char *file, int line, const char *dirname, int mode)
        if (0 == _mkdir(dirname))
                return (1);
 #else
-       if (0 == mkdir(dirname, mode)) {
-               if (0 == chmod(dirname, mode)) {
+       if (0 == mkdir(dirname, (mode_t)mode)) {
+               if (0 == chmod(dirname, (mode_t)mode)) {
                        assertion_file_mode(file, line, dirname, mode);
                        return (1);
                }
@@ -2005,9 +2005,9 @@ assertion_make_file(const char *file, int line,
                return (0);
        }
 #ifdef HAVE_FCHMOD
-       if (0 != fchmod(fd, mode))
+       if (0 != fchmod(fd, (mode_t)mode))
 #else
-       if (0 != chmod(path, mode))
+       if (0 != chmod(path, (mode_t)mode))
 #endif
        {
                failure_start(file, line, "Could not chmod %s", path);
@@ -2096,7 +2096,7 @@ assertion_umask(const char *file, int line, int mask)
        assertion_count(file, line);
        (void)file; /* UNUSED */
        (void)line; /* UNUSED */
-       umask(mask);
+       umask((mode_t)mask);
        return (1);
 }
 
@@ -3568,7 +3568,7 @@ test_run(int i, const char *tmpdir)
        char logfilename[64];
        int failures_before = failures;
        int skips_before = skips;
-       int oldumask;
+       mode_t oldumask;
 
        switch (verbosity) {
        case VERBOSITY_SUMMARY_ONLY: /* No per-test reports at all */
index 18c130e90bd0fea71dc7fbd80174d4f487829557..7c8cafc3effde8c93e2c1238106152407127f4cb 100644 (file)
@@ -356,7 +356,7 @@ make_dir(const char *path, int mode)
                 */
                (void)unlink(path);
        }
-       if (mkdir(path, mode) != 0 && errno != EEXIST)
+       if (mkdir(path, (mode_t)mode) != 0 && errno != EEXIST)
                error("mkdir('%s')", path);
 }
 
@@ -700,7 +700,7 @@ recheck:
                        error("symlink('%s')", *path);
                info(" extracting: %s -> %s\n", *path, linkname);
 #ifdef HAVE_LCHMOD
-               if (lchmod(*path, mode) != 0)
+               if (lchmod(*path, (mode_t)mode) != 0)
                        warning("Cannot set mode for '%s'", *path);
 #endif
                /* set access and modification time */