From: Graham Percival Date: Tue, 7 Jan 2025 00:44:40 +0000 (-0800) Subject: Cast (mode_t)mode for POSIX functions (#2476) X-Git-Tag: v3.7.8~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=91e81431b194afe21c0f08c965b3c72e818f5dd5;p=thirdparty%2Flibarchive.git Cast (mode_t)mode for POSIX functions (#2476) (cherry picked from commit 42565b88b5cc7441239269902a9d1735fd9ca0e2) --- diff --git a/libarchive/archive_write_disk_posix.c b/libarchive/archive_write_disk_posix.c index 899f50f50..6b6ded739 100644 --- a/libarchive/archive_write_disk_posix.c +++ b/libarchive/archive_write_disk_posix.c @@ -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, diff --git a/test_utils/test_main.c b/test_utils/test_main.c index d20004326..80d969caf 100644 --- a/test_utils/test_main.c +++ b/test_utils/test_main.c @@ -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 */ diff --git a/unzip/bsdunzip.c b/unzip/bsdunzip.c index 18c130e90..7c8cafc3e 100644 --- a/unzip/bsdunzip.c +++ b/unzip/bsdunzip.c @@ -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 */